It's like a teleporter there and back again!
ember install ember-receive
There are many uses for ember-receive
, but one of the main uses is to unblock blocked components.
Let me show you with a contrived example:
In another place:
Check out the demo, npm start
and http://localhost:4200
.
And consume:
- first parameter - Name of the source where the receiver can pick it up, this is required but doesn't have to be unique. String.
- second parameter - The data to pass to the source. This can be anything, primitive, object, array or a hash of contextual components.
blockTracking
- Prevent the receiver from sending back anything. Boolean, defaults tofalse
.autoPassBack
- Makes the receiver pass back everything in their yield automatically. Only works in 'single' mode. Boolean, defaults tofalse
.
- first parameter - Name of the source to reeive data from. Required.
- first yield - The data that is coming from the source.
mode
- How the receiver handles that data source. String, defaults to 'single'.- 'single' - Only one data object at a time, the yielded item is the data object.
- 'multiple' - Mutiple items at a time. The yielded item is an array of all of the raw
items, i.e.
{ data: <the data>, id: <sender id - unless
blockTracking>, passBack: <from
autoPassBack> }
.
- second yield - The send hash, which has one component at the moment:
back
- The teleport back to sender, used in block form and has no parameters/attributes. This will not send back if the sender has setblockTracking=true
.
Can also be used with an else
block:
This is based on the work in ember-portal (without which this wouldn't be possible) and the experiment to yield portals which opened new possibilities for me.