shaara-preset-base
v0.1.0
Published
Base preset for Shaara
Downloads
8
Readme
shaara-base-preset
Expose base services and behaviour to the Kernel. The main tools when developing a JS app are a Channel (to allow pub-sub management over the application) and an EventDispatcher that decouple the UI from the logic. The mind behind the EventDispatcher is that every time the user does an action that should have effects on the model layer (like fetching data) the UI should simply dispatch such an action with parameters and let handlers take care of it on the "model" side of the application. It helps a lot keep UI classes clear and it provides a pure way of handling actions, as dependencies are injected explicitly.
Services
- channel : Pub-sub pattern
- event.dispatcher : allows to dispatch event in a 1-1 way
- logger : provide a way to hold logs with a limit to avoid exceeding memory usage
Parameters
- fetch : if provided, the request sender will use this function instead of the global fetch. Indeed this preset rely on the fetch method. If you want to use Axios or Frisbee or example, you can easily write an adapter that follows the same API as fetch. One day we will provide a function "requestImplementation" to allow changing it easily.
Configuration
bindEvents : (eventDispatcher) => void
This is where you should bind your events to the dispatcher,
using eventDispatcher.set(name, callback)
.