Description
Environment
- Ocelot [v0.14.5]
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:
HH.slot unit Dropdown.componont
{ items: state.items
, selectedItem: state.selectedItem
, render: renderDropdown
}
But then when state.items
changes, the dropdown component won't be notified. If we update the typeahead and dropdown components with a receiver
, we can respond to changes in input
from the parent.