What is best practice to pass data from parent to child of a child.

edited September 2012 in Newbie Questions
I am new to this enyo framework, I want to know how we can pass data to lower most child. Currently I'm storing data in published variable of Main Kind(parent) and than getting in its child by "this.owner.varName" and than again saving this to child published variable and getting the same in its child in same way.


  • edited September 2012
    Take a look at Events, which can be passed between Parents and Children (including data)

  • I need more informations to help you.

    How the data are send?
    • N -> N-1 -> N-2
    • N-2 -> N-1 -> N
    In fact the question is : Do you only know N or do you know N-2

    P.S. N, N-1 and N-2 are your elements, (N-2 is a child of N-1, and N-1 a child of N)

    The solution (whatever is the direction of data propagation) could be a Dispatcher/Listener design pattern (that can be achieved by enyo.Signals or by sending an custom event through children or parents)
  • Thanks twtomcat and MacFJA for your help..... I am propagating my data from N to N-2 but when i pass data, only N-1 is visible to N, N-2 comes in picture after N-1 is created. Can we use custom events for sending data from parent to grand children?
  • Usually, for a parent to push data into a child, the parent just calls a method on the child. To go the other direction, the child posts an event with the data attached.

    We have the waterfall and waterfallDown methods to allow sending events to your children. This is useful when you need to broadcast things. For example, in the CryptoTweets sample, I used waterfallDown to send letter guesses from the App/Controller to all the cells.
  • Thanks unwiredben for your help.....Thats works for me but for this we need to declare separate handler in every child to get the value and save that value in local variable for further processing. Do we have any JSON dictionary like ios dictionary in enyo which has global scope through out the application and we can easily store values by "key" and "value" and get the same from by "key" in any child or parent.
  • You can easily declare you own global data store, just create a global object variable and store values in its hashes. If you want that data stored across runs, use HTML5 localStorage. This isn't directly handled by Enyo, but nothing in the framework prevents that usage.
Sign In or Register to comment.