Skip to content

Globally Defined Model Events

Latest
Compare
Choose a tag to compare
@SinisterMinister SinisterMinister released this 19 Mar 16:27
· 10 commits to master since this release

Intaglio now supports setting event handlers that will be assigned to all models. This allows you to hook into events at a global level to provide ORM wide functionality. Say for instance you'd like to register all of your models with something after they've been instantiated. You could do something like this:

var registry = require('some-registry');

// Register the global event handler
ORM.registerGlobalEvent('init', function () {
    registry.register(this.getModelName()+'.'+this.get('id'), this);
});