1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    482
    Vote Rating
    0
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Question Promise-based event model?

    Promise-based event model?


    Hi,

    To reduce components coupling into my applications (ExtJS 3.x) , my components are only fireing events which are handled afterwards by the application or other components. This works well, but sometime, the component that have fired an event would like to be notified on how the event he fired was handled.

    For example, a SearchBar component could fire a search. The application would catch this event and perform a search. Now let's say the search failed because the search query syntax was wrong. We would then want to mark the SearchBar's input invalid.

    I have tought of 3 ways of solving this problem:

    - Use a global message/event bus. The message bus instance would have to be injected in each components that is using it to avoid coupling. Now with the example, the component could now listen to the searchfinished topic on the message bus (that would have been posted by the application) and could retrive the result and mark itself invalid.

    - Provide a public markInvalid method on the SearchBar component that would then be called after by the application.

    - Implement a new event model based on the Promise pattern. That would allow doing something like:
    Code:
    this.fireEvent(...).then(...);
    The Promise pattern seems to be the future of asynchronous programming and I think all ExtJS developers would greatly benefit from a new Promise-based event model.


    I would like to know how others would solve this problem and what they think about having a new event model based on the Promise pattern for ExtJS?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    436
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Please post in the appropriate forum. I have moved this to the Ext JS 3 help forum.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread