Inheriting hooks, I need endOfafterCreate etc

11 views
Skip to first unread message

Mark Lester

unread,
May 10, 2016, 7:04:53 PM5/10/16
to Sequelize
I load all my models from object files with the attrbs and also the relations and hooks in the same block so I can iterate over define and then go round and apply all the relations.
I now have several funky sets of hooks to apply across a whole set, one for sending sockets io stuff so I can have backbone models and collections listen for data or fetch commands. And I have another for a distributed system I have been writing.
So I just pass these to my loader as an array of base type hooks to stick on.

My problem now is, I may have a hook in my application model that wants to be done after all the additional plugins have run, an endOfafterCreate if you like.
So thats what I am doing. If you have an endOf<hook name> then after I've added any base hooks I will add that one at <hook name>.

Global hooks always get done after no matter what, so they wont work at all for this.

If this is a case of yes, that's what you will have to do, should I add this as a suggestion and implement if wanted ?

Mick Hansen

unread,
May 11, 2016, 4:26:48 AM5/11/16
to Mark Lester, Sequelize
We've previously had named hooks on the drawing boards, and then being able to prepend/append named hooks, that might work here.
--
Mick Hansen
@mhansendev
mhansen.io

Mark Lester

unread,
May 11, 2016, 7:03:41 AM5/11/16
to Sequelize, mark.chr...@gmail.com
and i have another functionality add on, a history table feature which i wrote for wikitimetable.
I will continue coming up with a scheme to be able to plug things like this in. I got dragged off WT to do something that might actually make money, but as a result i can now have a leaflet map editor that will distribute your edits live to someone else looking at the same place. all using the standard stuff, including a genuine leaflet marionette view (i.e not one which uses geoJSON which isnt really getting us anywhere)  which is perhaps overkill but pretty awesome all the same.

may be
sequelize.applyModule(require('sequelize-notifier'))

to be applied after you've set your models up but before sync.


Mick Hansen

unread,
May 11, 2016, 7:05:59 AM5/11/16
to Mark Lester, Sequelize
I'm not sure we want to enforce a pattern for how plugins inject.
Rather i'd just provide the proper tools and a guideline for where to inject.

Mark Lester

unread,
May 13, 2016, 11:04:15 AM5/13/16
to Sequelize, mark.chr...@gmail.com
do we have any guidelines on this.
i am hoping to refactor out things like my sequence implementation (declare a field as sequence:true, and others as sequenceIndex:ltrue, and stop worrying about managing your polylines etc). there's loads of stuff like this we could be sharing.
Reply all
Reply to author
Forward
0 new messages