From dc0f6a3f64a1544817b200a8e626ab6e7b8b9405 Mon Sep 17 00:00:00 2001 From: Jeremy Gore Date: Fri, 12 Mar 2021 09:28:49 -0500 Subject: [PATCH] Handle functional set/redo calls --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 21b0330..e676cea 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,10 @@ const reducer = (state, action) => { } case SET: { - const { newPresent } = action; + let { newPresent } = action; + if (typeof newPresent === 'function') { + newPresent = newPresent(present); + } if (newPresent === present) { return state; @@ -51,7 +54,10 @@ const reducer = (state, action) => { } case RESET: { - const { newPresent } = action; + let { newPresent } = action; + if (typeof newPresent === 'function') { + newPresent = newPresent(present); + } return { past: [],