Deep dive on MotorCortex’s operation

Even though in terms of code creating a plugin is easy, still before you go on and create your first plugin is good to know some insight information that will help you nail it.

As mentioned all Incidents are been applied to specific elements via the “selector” key of their props.

Also, we’ve already mentioned that the only context provider is the Clip. The native Clip class provided by MotorCortex renders the, provided on props, HTML (and CSS) on the specified host and this block on the DOM is the context of it. Any Incident that will ever enter the Clip’s tree can only affect elements belonging to the Clip’s context, via the “selector” of its props.

If a Clip is contained on another Clip as CASI then every Incident that it’s contained in the CASI has as its context the CASI’s context and so on.

MotorCortex allows developers to define Incidents (or even trees of Incidents) that do not belong to a Clip yet. For example you could instantiate a Group and put three Incidents on it. Up to that point neither the Group nor the Incidents have context as they do not belong to any Clip (the exclusive context provider). Up to that point all Group and the three Incidents are on the (as we call it) “Descriptive” state. The moment the Group enters the context of a Clip it “gets context”. This is the point that the method “onGetContext” of each Incident is been executed. This is the ideal moment to execute initialisation operations on your Incident as you now have access to your element.