lodestarjs/lodestar-ractive

Changing the `controller` property function name?

Opened this issue · 12 comments

At the moment if you're not separating out the controllers into separate files, the controller object will look like the following example, where I'm not sure I like the repetition of the attribute controller:

controller: {

  controller: function() { },

  actions: {},

  observe: {},

  observeOnce: {}
}

Maybe we could change the controller function to something like onLoad or init?

@xCausxn, @silverlight513 and anybody else, any suggestions?

I agree, init or methods something like that to make the flow cleaner

@xCausxn, I remember that Ember uses setupController which I guess does what is says on the tin... but I am leaning towards init.

@xCausxn do you prefer onInit or just simply init? The property will be executed when the controller is initialised after the Ractive View has been activated.

controller: {

  init: function() { },
  // OR
  onInit: function() {},

  actions: {},

  observe: {},

  observeOnce: {}

}

Hard choice but I would probably say onInit

Changes have been made on my branch, I will merge it in once tests & coverage has been added.

Actually @xCausxn, maybe not onInit as I've noticed that Ractive has an oninit event so it could become confusing when using components etc... Maybe onSetup?

run or onSetup

why not just call it 'main'

onControllerLoad might be another option.

Could change everything to ES6 classes, and then run babel over it. Same way angular is doing it and I find it really nice, constructor can then be utilised, then anything else you need make a method for it.

There is already a nice flow in place using ES6 modules.

I don't know if it makes sense to switch everything to a flow revolving around ES6 classes as Lodestar-Ractive follows the MVC pattern whereas Angular 2 focuses much more on using components which contain their own logic rather than having controllers which are conceptually different.