ciebit/js-hermes

对象间通信管理模块

安装: 237

依赖者: 2

建议者: 0

安全: 0

类型:ciebit-js

3.0.1 2017-10-26 18:22 UTC

This package is auto-updated.

Last update: 2024-09-08 14:30:07 UTC


README

事件通信模块。

安装

浏览器

Ciebit 模块是为了与 RequireJs 一起工作而设计的项目,使用时只需将其作为依赖项传递,如下所示

#!javascript
require(["@ciebit/hermes"], function(hermes){
    // Utilizar aqui
});

并在配置中添加

#!javascript
require.config({
    paths: {
        "@ciebit/hermes": "//js.ciebit.com/hermes/v3.0.0.js"
    }
});

通过 NPM

要将它嵌入到项目中,可以通过以下命令下载

#!shell
npm install @ciebit/hermes

使用方法

您可以使用 Hermes 来存储请求和回调函数。例如:

#!typescript
import { Hermes } from "@ciebit/hermes";

let HermesObj:Hermes = new Hermes;

/*
Aqui é passando como primeiro parâmetro um identificador do evento
e no segundo uma função de callback
*/
HermesObj.aviseMe('ativado', function(){ console.log('Fui ativado') });


/*
A função informada acima será chamada com o comando abaixo
*/
HermesObj.avise('ativado');