Document Data Sharing from a Piral Instance
See original GitHub issueNew Feature Proposal
For more information, see the CONTRIBUTING
guide.
Description
Currently we allow pilets to share data using the Piral API by calling setData
and getData
to store into some global key/value store. I’d like to see the ability to have some data set into this by the base piral instance on render.
Background
The use case for this is for sharing user information to pilets. Currently, we expect the instance to render only to authenticated users. We pull some user information (such as email) from an API when rendering the Menu component in order to generate portions of the menu. When we do so, we’d like to have the ability to make the user information available to all the other pilets.
Discussion
Biggest pro here is being able to boootstrap data from the main piral instance and have that piral instance manage the data for the other pilets. This is useful for any sort of global data that isn’t necessarily spawned/acquired by a specific pilet.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Thanks for the help! I’ll give it a shot and see if I run into any other issues.
If your component lives anyway in the app shell (sounds like it for the menu) then instead of passing in a prop “couple” it to the global state container.
Instead of the logic operation you could also use
data?.value
if you already use the next gen / latest version of TypeScript.Since this way you are “connected” to the global state container your component will re-render on change.
Hope that helps!