Special lifecycle callbacks separated from other properties #47

Open
wilsonpage opened this Issue Oct 3, 2013 · 5 comments

Comments

Projects
None yet
2 participants
Contributor

wilsonpage commented Oct 3, 2013

As inspired by x-tags the clear separation of lifecycle callbacks and other custom properties.

var Apple = fm.define({
  name: 'apple',
  template: template,
  lifecycle: {
    initialize: function() {},
    setup: function() {},
    teardown: function() {},
    destroy: function() {}
  },
  myAppleMethod: function() {}
});

or possible reverting to old style:

var Apple = fm.define({
  name: 'apple',
  template: template,
  onInitialize: function() {},
  onSetup: function() {},
  onTeardown: function() {},
  onDestroy: function() {}
  myAppleMethod: function() {}
});

or titled callbacks:

var Apple = fm.define({
  name: 'apple',
  template: template,
  callbacks: {
    initialize: function() {},
    setup: function() {},
    teardown: function() {},
    destroy: function() {}
  },
  myAppleMethod: function() {}
});
Member

matthew-andrews commented Oct 3, 2013

I think you mean (JS object not function)

lifecycle: {
  initialize: function() {},
  setup: function() {},
  teardown: function() {},
  destroy: function() {}
}

Would it be worth considering renaming them to be x-tagsy too?
initialize => created
setup => inserted
teardown => removed
destroyed left as is

This would require some amendments deeper down in fruitmachine to make fruitmachine objects' lifecycles more in tune with the web component spec. I feel that could be a good thing.

Member

matthew-andrews commented Oct 3, 2013

(Basically leave it up to fruitmachine to intelligently call setup and teardown)

Member

matthew-andrews commented Oct 3, 2013

(In order to mitigate the migration pain we could provide an global fruitmachine option to switch auto-setup on and off)

Member

matthew-andrews commented Oct 3, 2013

(Or we could just implement it and make the setup() / teardown() methods on module API do nothing and remove them from the codebase as a second step)

Member

matthew-andrews commented Oct 3, 2013

Can we change tag to extends as well?
http://www.x-tags.org/#custom-tag-registration-extends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment