ax1 / iridiumjs

🚀 Boost HTML horsepower
MIT License
1 stars 0 forks source link

ir.controller.configure(,{customMethods},) should get "this" assigned to the controller #12

Closed ax1 closed 7 years ago

ax1 commented 7 years ago

When any method is defined in the controller, the this object is the controller itself ir.controller().myMethod=funct(){//this===controller}

This behavior should be the same for the custom methods that are executed after REST calls, that is, these functions should get the controller as this object (currently, this=>the object containing the customMethods, that is useless)

Possible solutions

don't forget to update documentation on create read update remove...

ax1 commented 7 years ago

Custom methods now have the implicit this object assigned to the controller.

Note: the custom functions can be declared either as function() {} or as arrow () => {} but the first is preferred for these functions since the arrow assigns the this in runtime and it could be a different object than the controller.

See controller for examples.