Plugins Cheat Sheet

Signature

It is a good practice to allow your users to pass in an additional
plugin configuration object, thus reaching a final shape like this:

exportconst yourPlugin =(pluginConfig ={})=>{return({ entityConfigs, config, addChangeListener })=>{// Use this space to setup additional data structures and helpers,// that act across entities.return({ entity, fn })=>{// Use this space to setup additional data structures and helpers,// that act on a single entity.return(...args)=>{// Do your magic here!// Invoke the original fn with its arguments or a variation of it.returnfn(...args);};};};};

We commonly refer to this process as create => setup => decorate
steps, with the final goal of producing a decorated ApiFunction.

Apply a plugin

Pass plugins in a list of plugins as an optional second argument to
Ladda's build function.