mag.js icon indicating copy to clipboard operation
mag.js copied to clipboard

unload LF event for inner modules

Open magnumjs opened this issue 10 years ago • 0 comments

It would be nice to be able to execute on unload life cycle event for a module inside a module that was attached to the state and then removed.

For example

mag.module('unloader', {
  view: function(state) {
    state.button = {_onclick:function(){
      state.count = state.count + 1 || 1
    }
    }
    state.mod = state.count%2 == 0 ? mag.module('testmod', {
      controller: function() {
        this.onunload = function() {
          console.log('removed from state')
        }
      },
      view: function() {}
    }) : null
  }
})

magnumjs avatar May 04 '15 10:05 magnumjs