orki-notification

1.0.11 • Public • Published

orki-notification

Projeto para facilitar a integração com o recurso de notificação do orki framework

Instalação

npm i orki-notification --save

Import

import notification from 'orki-notification'

Exemplos

Configurando endpoint e token

/**
 * Configure
 */
notification.set('endpoint', environment.apiUrl)
notification.set('token', () => localStorage.getItem('jwt'))

Abrindo escuta a um schema.

notification.open('module', 'SCHEMA', { scope: 'myScope' })
    .then(socket => {
        socket.on('message', function(a){
            // Um exemplo de como fechar a conexão websocket
            setTimeout(socket.close.bind(socket), 1000 * 10)
        })
    })

Abrindo escuta a um schema usando async e await.

const socket = await notification.open('module', 'SCHEMA', { scope: 'myScope' })
    
socket.on('message', function(a){
    // Um exemplo de como fechar a conexão websocket
    setTimeout(socket.close.bind(socket), 1000 * 10)
})

Readme

Keywords

none

Package Sidebar

Install

npm i orki-notification

Weekly Downloads

53

Version

1.0.11

License

MIT

Unpacked Size

420 kB

Total Files

11

Last publish

Collaborators

  • willguitaradmfar