dapplets / dapplet-modules

Dapplet Extension: Examples of Using
MIT License
2 stars 0 forks source link

introduce group subscription handlers #10

Open ethernian opened 5 years ago

ethernian commented 5 years ago

it should be possible to define event handlers on the global level of the feature or on the group of the same buttons. These events will cause changes on widgets initiated from outside.

sketching idea

class SomeFeature implements IFeature {
   @Load('likesService.public.name') 
   private likesService;
   ...
    button({ // `this` is bound to the button instance
        label: likesService.send(this)
              .on(()=>this.state=WAITING)  //null filter may stay for subscription status events
              .on('likeChanged', likeNr => this.label=likeNr)    // likeNr changed by *this* widget 
        ...
        on : {
               tx_running: ()=> this.state=WAITING;
               like_changes: (likeNr) => this.like = likeNr; // likeNr changed by *some other* widget 
        }
     });
   ...
}//clazz
ethernian commented 5 years ago

@alsakhaev : what is the semantic difference between actions defined in button directly (like exec ) and those defined on section on: { ... } ?

Example from sencha:

Ext.create('Ext.Button', {
    renderTo: Ext.getBody(),
    text: 'My Button',
    listeners: {
        mouseover: function() {
            this.hide();
        },
        hide: function() {
            // Waits 1 second (1000ms), then shows the button again
            Ext.defer(function() {
                this.show();
            }, 1000, this);
        }
    }
 });
ethernian commented 5 years ago

Which of implementation strategies is the better one?

  1. individual event handler for each widget instance?
  2. the same group event handler for each widget instance with the widget as a parameter?