-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic bind
API
#43
Comments
There is a lot of ways in React to get dynamic data using hooks. // Simple hook
const data = useHook();
// Hook with params
const data = useHook(params);
// Hook with callback
const data = useHook(() => new Class());
// Hook returning array
const [data] = useHook();
// Hook returning object
const {data} = useHook();
// Hook that depends on other hook data
const dataOne = useHookOne();
const dataTwo = useHookTwo(dataOne); Also with your implementation if you use multiple keys from the factory bind: {
value: take(factory, "$value"),
valueChange: take(factory, "valueChange")
} The factory It might be much more flexible to add a hook property that will gather all the data and then add it to a const SomeInput = reflect({
view: Input,
bind: {
value: $value
},
useDynamicBind: (componentProps) => {
const hookWithPropsData = useHook(componentProps.transactionId);
const hookThatDependsData = useDependentHook(hookWithPropsData);
const {$store, storeChange} = factory.useModel();
return { $store, storeChange, hookThatDependsData }
}
}) |
What about API like this? const SomeInput = reflect({
view: Input,
bind: {
value: factory.fromModel((model) => model.$value),
},
}) |
But actually I think we can implement |
With |
I think {
useSource: props => something.useSource(props),
fn: () => Unit
} |
This RFC solves impossibility to combine
@effector/reflect
andeffector-factorio
, as well as adding protocol to integrate other dynamic bindings in a futureHow does it look?
It looks like this:
take
returns the following structure:In
effector-factorio
we will add this alias:And then we will be able to combine them:
Also
(source, props) => key
variant forkey
in order to support dynamic factories (they're not welcome but technically possible)fromProps(key) === take({ useSource: props => props, key)
shorthand that allows to take store from just propsWhy this API? Why not
bind: props => ({ ... })
?effector-factorio
only, it doesn't even have its mention@effector/reflect
and 1 alias ineffector-factorio
The text was updated successfully, but these errors were encountered: