1.2.3 • Published 10 years ago

jemjs v1.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

JEM

What is JEM?

JEM provides minimal functionality helping you to keep cleaner codebase with less dependencies.

How does it work?

Getting started

Installation

    npm i jemjs --save-dev
    import { JEM } from jemjs;

Reference

JEM.On(eventName, ...listener)

Subscribes one or multiple listeners to an event.

    JEM.On(
        'eventName', 
        () => { /* your code here */ }
    );

Mutliple listeners can subscribe to On too.

    JEM.On(
        'eventName', 
        () => { /* _your code here */ }, 
        (x) => { /* Arguments can be provided by JEM.Emit. */ }
    );

JEM.Once(eventName, ...listener)

Subscribes one or multiple listeners to an event. Listenery bound with Once will be dispatched after the first call.

    JEM.Once(
        'incrementCount', 
        () => { /* your code here */ }
    );

Multiple listeners can subscribe to Once too.

    JEM.Once(
        'increment', 
        () => { /* _your code here */ }, 
        (x) => { /* Arguments can be provided by JEM.Emit. */ }
    );

JEM.Emit(eventName, ...listenerArgs)

Calls all listeners subscribed to the specified event.

    // Call all subscribers for the event "eventName"
    JEM.Emit('eventName');

    //Works with arguments too.
    JEM.Emit('eventName', 1337);

    //Even with a lot arguments
    JEM.Emit('eventName', 1, 2, 3, 4, 'a', 'b');

JEM.Dispatch

Removes a listener or a complete event.

    JEM.Dispatch('eventName'); // Removes the specified event. All listeners are gone.

    function increment(x) {
        return ++x;
    }

    JEM.Dispatch('eventName', increment); //Removes this listener.

JEM.Clear

Removes all events (and all listeners).

    JEM.Clear();

JEM.Isolate

Creates a new isolated JEM-scope. By default theres only one global JEM-scope. Isolated scopes provided the same functionality like the global JEM-scope except the Isolate function is not present.

    const isolatedJEM = JEM.Isolate();
1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago