monitos.io

    1.0.1 • Public • Published

    Monitos

    Monitos.IO

    An extension of Monitos where all events are emitted to Socket.IO.

    Example:

    Monito.openSocket(9183);            // Socket.IO server on port 9183
     
    let chimp = new Monito({
        initialState: 'register',
        states: {
            register: (next) => {
                next(null, 'getProfile');   // Go straight to the state "getProfile"
            },
            getProfile: (next) => {
                next(null, {
                    browse: 4               // If your dice rolls 4 or more, go to "browse"
                }, 'shop');                 // Otherwise, by default, go to "shop"
            },
            browse: (next) => {
                next(null, {
                    browse: monito => 6     // You can also use functions
                }, 'shop');                 
            },
            shop: (next) => {
                next(null, 'logout');       // Go straight to the state "logout"
            },
            logout: (next) => {
                next();                     // This will be the last state
            }
        }
    });
     
    chimp.start();

    See the full code of the example.

    Usage

    Monito.openSocket(9183);
    
    let chimp = new Monito(states, initialState);
    
    chimp.on('end', () => {
        Monito.closeSocket()
    });
    

    Static methods

    • Monito.openSocket(arguments) - Initializes Socket.IO. For a full list of options, check the Socket.IO documentation.
    • Monito.closeSocket() - Closes Socket.IO socket.
    • Monito.getSocket() - Returns the Socket.IO socket.

    Arguments

    There are no new constructor arguments. For a full list of arguments, check the Monitos documentation.

    Events

    There are no new events. For a full list of events, check the Monitos documentation.

    API

    There are no new API methods. For a full list, check the Monitos documentation.

    Testing

    Run all the tests (linting and unit tests) with the following npm task:

    > npm test
    

    You can run the linting and the unit tests individually:

    > gulp test
    > gulp lint
    

    License

    MIT

    Install

    npm i monitos.io

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • dunkelheit