-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add receiver
to typeaheads and dropdowns
#79
Comments
We have to do this manually in order to address: citizennet/purescript-ocelot#79. The changes here allow the `options` to actually be dynamic. Unfortunately, we have to remove the tests on the queries because of that. There's no easy way to evaluate a `HalogenM _ _ _ _ _ _ _`. Maybe someone will release an easy way to do this in the future, and we can use that. Until then, we're testless for our `eval`.
@davezuch Remember when we had a flag for this, called |
@thomashoneyman I don't recall. We got rid of this though? I was thinking on this more, and I don't think we can support both styles at the same time (without some conditional |
@davezuch I implemented it in a branch, but we didn't end up needing it, so we never merged it. It ended up being something like: type Input = { listen :: Boolean, ... }
data Query a = Receive Input a
component = H.component { receiver: Just <<< Receive, ... }
where
eval = case _ of
Receive input a -> do
when input.listen do
H.modify_ _ { items = input.items }
pure a so that the receiver query is always run, but it only sets its items to the parent's items when it is listening, and if it is not listening, then it preserves its own items without overwriting them with new input |
@thomashoneyman that seems like a good solution, I might just use it. Thanks! |
Environment
Current behavior
Currently you can set the initial items for a dropdown or typeahead via either the parent's render function, or the parent's eval by sending the child component the appropriate query. However, the only way to update the items for a dropdown or typeahead is from the parent eval via a child query.
Expected behavior
There are two scenarios for managing the items for a component:
1. letting the child fully manage them
In this scenario, the parent fetches the items once and passes them to the child, or provides the child a function for fetching them itself—as with an async typeahead. In this scenario, the parent needn't ever hold on to the items in its own state. This scenario is currently supported by Ocelot.
2. the parent manages the items
In this scenario, the parent has reason to deal with the items and hold onto them in state, and the child should be able to basically use the items that are managed on the parent state. This scenario is only partially supported, and requires manually updating the child's items.
Currently, the items on the parent's state can be passed to a dropdown like so:
But then when
state.items
changes, the dropdown component won't be notified. If we update the typeahead and dropdown components with areceiver
, we can respond to changes ininput
from the parent.The text was updated successfully, but these errors were encountered: