pepsighan / ruukh-ui

An experimental next-gen frontend framework for the Web in Rust.
MIT License
0 stars 1 forks source link

How to raise event to parent manually? #31

Open Boscop opened 6 years ago

Boscop commented 6 years ago

The component example shows how to forward an event from a child of self to self's parent. But how can self raise an event to self's parent manually (e.g. in an event handler)?

And how can msgs be dispatched on a child (or how can a component react to one of its props being changed) / how can children be queried about their state?

IOW, how to do these:

raising an event to the parent: https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/basic/src/Button.purs#L51 handling it in the parent: https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/components/src/Container.purs#L65-L67

child querying (for requests with response or just setting child state): https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/components/src/Container.purs#L69 https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/components/src/Button.purs#L55-L57 example 2: https://github.com/slamdata/purescript-halogen/blob/e51eee0afd4f9816a64242f9c4a7b67ffc157e7b/examples/components-multitype/src/Container.purs#L79-L81 https://github.com/slamdata/purescript-halogen/blob/e51eee0afd4f9816a64242f9c4a7b67ffc157e7b/examples/components-multitype/src/ComponentA.purs#L47-L48

reacting to prop changes: https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/components-inputs/src/Display.purs#L24 https://github.com/slamdata/purescript-halogen/blob/edc007a584e00471af89102ef0f31cb53047c4a1/examples/components-inputs/src/Display.purs#L39-L42