-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
This RFC solves impossibility to combine @effector/reflect and effector-factorio, as well as adding protocol to integrate other dynamic bindings in a future
How does it look?
It looks like this:
import { reflect, take } from '@effector/reflect'
const SomeInput = reflect({
view: Input,
bind: {
value: take(something, key)
}
})take returns the following structure:
{
/** Telling `reflect` how to extract the dynamic source of units */
useSource: props => something.useSource(props),
/** `key` that takes unit from source */
key: key
}In effector-factorio we will add this alias:
factory.useSource = factory.useModel // Takes model instance from React.ContextAnd then we will be able to combine them:
const factory = modelFactory(() => {
return {
$value: createStore("")
}
})
const SomeInput = reflect({
view: Input,
bind: {
value: take(factory, "$value")
}
})Also
- We should also support
(source, props) => keyvariant forkeyin order to support dynamic factories (they're not welcome but technically possible) - We could also add
fromProps(key) === take({ useSource: props => props, key)shorthand that allows to take store from just props
Why this API? Why not bind: props => ({ ... })?
- No breaking changes
- We still statically get all non-dynamic bindings
- This API is not limited/specific for
effector-factorioonly, it doesn't even have its mention - Adds only 10 lines of code in
@effector/reflectand 1 alias ineffector-factorio
sergeysova and wise-danya
Metadata
Metadata
Assignees
Labels
No labels