Last active
March 24, 2021 15:16
-
-
Save c01nd01r/cd9e1066eb1a84940e71d85edf3d94ca to your computer and use it in GitHub Desktop.
effector forward object of events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const startApp = createEvent(); | |
const handleSuccess = createEvent(); | |
const handleFail = createEvent(); | |
forward({ | |
from: startApp, | |
to: fxFetchUser, | |
}) | |
// this | |
forward({ | |
from: fxFetchUser.doneData, | |
to: handleSuccess | |
}) | |
// ... <-- any looong code block here for success case | |
forward({ | |
from: fxFetchUser.doneData, | |
to: handleFail | |
}) | |
// or this? | |
effector({ | |
clock: fxFetchUser | |
cases: { | |
doneData: successHandle, | |
faldData: failHandle, | |
} | |
}) | |
// For factories | |
const socket = createSocket(); | |
effector({ | |
clock: socket, | |
cases: { | |
connected: updateViewLoader, | |
received: parseMessage, | |
closed: reconnect, | |
killed: showError, | |
failed: showError, | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment