What is a Ferp Subscription?
The Basics
import { app, effects } from 'ferp';
const yourIntervalSubscription = (dispatch, interval, intervalAction) => {
const handle = setInterval(
() => dispatch(intervalAction),
interval,
);
return () => {
clearInterval(handle);
};
};
// And to use it:
app({
init: [
{ someBooleanValue: false },
],
subscribe: (state) => [
[yourSubscription, 1000, effectFunctionA],
[yourSubscription, 3000, effectFunctionB],
state.someBooleanValue && [yourSubscription, 1000, effectFunctionC],
],
});The Subscribe Array
When to use a subscription
Last updated