-
-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
RFCSome new feature that should be discussedSome new feature that should be discussed
Description
One of key features of spread is an ability to skip updates for some targets, but it requires object mutation or weird conditionals (it becomes worse when amount of targets grows):
sample({
clock: trigger,
fn: upd => upd.both
? ({foo: 0, bar: 0})
: ({foo: 0})
target: spread({
foo,
bar,
})
})
// or
sample({
clock: trigger,
fn(upd) {
const result = {foo: 0}
if (upd.both) {
result.bar = 0
}
return result
},
target: spread({
foo,
bar,
})
})
We can add special token SKIP which will mean that this unit will not be triggered:
import {spread, SKIP} from 'patronum'
// or maybe spread.SKIP
sample({
clock: trigger,
fn: upd =>({
foo: 0,
bar: upd.both ? 0 : SKIP
}),
target: spread({
foo,
bar,
})
})
Metadata
Metadata
Assignees
Labels
RFCSome new feature that should be discussedSome new feature that should be discussed