rasa-0.1.0.0: A modular text editor

Safe HaskellNone
LanguageHaskell2010

Rasa.Internal.Scheduler

Synopsis

Documentation

newtype Scheduler a Source #

The Scheduler is how you can register your extension's actions to run at different points in the editor's event cycle.

The event cycle proceeds as follows:

    Init  (Runs ONCE)

    -- The following loops until an exit is triggered:
    BeforeEvent -> (any event) -> BeforeRender -> OnRender -> AfterRender

    Exit (Runs ONCE)

Each extension which wishes to perform actions exports a Scheduler () which the user inserts in their config file.

Constructors

Scheduler 

Fields

Instances

data Hook Source #

A wrapper around event listeners so they can be stored in Hooks.

type Hooks = Map TypeRep [Hook] Source #

A map of Event types to a list of listeners for that event

afterRender :: Action () -> Scheduler () Source #

Registers an action to be performed AFTER each render phase.

This is useful for cleaning up extension state that was registered for the renderer, but needs to be cleared before the next iteration.

beforeEvent :: Action () -> Scheduler () Source #

Registers an action to be performed BEFORE each event phase.

beforeRender :: Action () -> Scheduler () Source #

Registers an action to be performed BEFORE each render phase.

This is a good spot to add information useful to the renderer since all actions have been performed. Only cosmetic changes should occur during this phase.

dispatchEvent :: Typeable a => a -> Action () Source #

Use this to dispatch an event of any type, any hooks which are listening for this event will be triggered with the provided event. Use this within an Action.

eventListener :: forall a. Typeable a => (a -> Action ()) -> Scheduler () Source #

This registers an event listener hook, as long as the listener is well-typed similar to this:

MyEventType -> Action () then it will be registered to listen for dispatched events of that type. Use within the Scheduler and add have the user add it to their config.

getHooks :: Scheduler () -> Hooks Source #

Transform a Scheduler monad into a Hooks map.

matchingHooks :: forall a. Typeable a => Hooks -> [a -> Action ()] Source #

This extracts all event listener hooks from a map of hooks which match the type of the provided event.

onExit :: Action () -> Scheduler () Source #

Registers an action to be performed during the exit phase.

This is only triggered exactly once when the editor is shutting down. It allows an opportunity to do clean-up, kill any processes you've started, or save any data before the editor terminates.

onInit :: Action () -> Scheduler () Source #

Registers an action to be performed during the Initialization phase.

This phase occurs exactly ONCE when the editor starts up.

onRender :: Action () -> Scheduler () Source #

Registers an action to be performed during each render phase.

This phase should only be used by extensions which actually render something.