@nextcloud/event-bus
Advanced tools
Comparing version 1.0.1 to 1.1.2
@@ -5,4 +5,12 @@ # Changelog | ||
## 1.1.2 - 2020-01-10 | ||
### Fixed | ||
- Packaging of corejs | ||
## 1.1.1 - 2020-01-10 | ||
### Fixed | ||
- Module error with semver package | ||
## 1.0.1 - 2020-01-07 | ||
### Fixed | ||
- Misleading warning if ProxyBus is used for a compatible bus |
var typedoc = typedoc || {}; | ||
typedoc.search = typedoc.search || {}; | ||
typedoc.search.data = {"kinds":{"1":"External module","2":"Module","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"lib/Event\"","url":"modules/_lib_event_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"Event","url":"interfaces/_lib_event_.event.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"lib/Event\""},{"id":2,"kind":1,"name":"\"lib/EventHandler\"","url":"modules/_lib_eventhandler_.html","classes":"tsd-kind-external-module"},{"id":3,"kind":256,"name":"EventHandler","url":"interfaces/_lib_eventhandler_.eventhandler.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"lib/EventHandler\""},{"id":4,"kind":1,"name":"\"lib/EventBus\"","url":"modules/_lib_eventbus_.html","classes":"tsd-kind-external-module"},{"id":5,"kind":256,"name":"EventBus","url":"interfaces/_lib_eventbus_.eventbus.html","classes":"tsd-kind-interface tsd-parent-kind-external-module","parent":"\"lib/EventBus\""},{"id":6,"kind":2048,"name":"getVersion","url":"interfaces/_lib_eventbus_.eventbus.html#getversion","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"lib/EventBus\".EventBus"},{"id":7,"kind":2048,"name":"subscribe","url":"interfaces/_lib_eventbus_.eventbus.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"lib/EventBus\".EventBus"},{"id":8,"kind":2048,"name":"unsubscribe","url":"interfaces/_lib_eventbus_.eventbus.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"lib/EventBus\".EventBus"},{"id":9,"kind":2048,"name":"emit","url":"interfaces/_lib_eventbus_.eventbus.html#emit","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"\"lib/EventBus\".EventBus"},{"id":10,"kind":1,"name":"\"lib/ProxyBus\"","url":"modules/_lib_proxybus_.html","classes":"tsd-kind-external-module"},{"id":11,"kind":128,"name":"ProxyBus","url":"classes/_lib_proxybus_.proxybus.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"lib/ProxyBus\""},{"id":12,"kind":1024,"name":"bus","url":"classes/_lib_proxybus_.proxybus.html#bus","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":13,"kind":512,"name":"constructor","url":"classes/_lib_proxybus_.proxybus.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":14,"kind":2048,"name":"getVersion","url":"classes/_lib_proxybus_.proxybus.html#getversion","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":15,"kind":2048,"name":"subscribe","url":"classes/_lib_proxybus_.proxybus.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":16,"kind":2048,"name":"unsubscribe","url":"classes/_lib_proxybus_.proxybus.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":17,"kind":2048,"name":"emit","url":"classes/_lib_proxybus_.proxybus.html#emit","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/ProxyBus\".ProxyBus"},{"id":18,"kind":1,"name":"\"lib/SimpleBus\"","url":"modules/_lib_simplebus_.html","classes":"tsd-kind-external-module"},{"id":19,"kind":128,"name":"SimpleBus","url":"classes/_lib_simplebus_.simplebus.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"lib/SimpleBus\""},{"id":20,"kind":1024,"name":"handlers","url":"classes/_lib_simplebus_.simplebus.html#handlers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"lib/SimpleBus\".SimpleBus"},{"id":21,"kind":2048,"name":"getVersion","url":"classes/_lib_simplebus_.simplebus.html#getversion","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/SimpleBus\".SimpleBus"},{"id":22,"kind":2048,"name":"subscribe","url":"classes/_lib_simplebus_.simplebus.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/SimpleBus\".SimpleBus"},{"id":23,"kind":2048,"name":"unsubscribe","url":"classes/_lib_simplebus_.simplebus.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/SimpleBus\".SimpleBus"},{"id":24,"kind":2048,"name":"emit","url":"classes/_lib_simplebus_.simplebus.html#emit","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"lib/SimpleBus\".SimpleBus"},{"id":25,"kind":1,"name":"\"lib/index\"","url":"modules/_lib_index_.html","classes":"tsd-kind-external-module"},{"id":26,"kind":2,"name":"__global","url":"modules/_lib_index_.__global.html","classes":"tsd-kind-module tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"lib/index\""},{"id":27,"kind":256,"name":"Window","url":"interfaces/_lib_index_.__global.window.html","classes":"tsd-kind-interface tsd-parent-kind-module tsd-is-not-exported","parent":"\"lib/index\".__global"},{"id":28,"kind":1024,"name":"OC","url":"interfaces/_lib_index_.__global.window.html#oc","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"lib/index\".__global.Window"},{"id":29,"kind":1024,"name":"_nc_event_bus","url":"interfaces/_lib_index_.__global.window.html#_nc_event_bus","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"lib/index\".__global.Window"},{"id":30,"kind":64,"name":"getBus","url":"modules/_lib_index_.html#getbus","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"lib/index\""},{"id":31,"kind":32,"name":"bus","url":"modules/_lib_index_.html#bus","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"lib/index\""},{"id":32,"kind":32,"name":"subscribe","url":"modules/_lib_index_.html#subscribe","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"lib/index\""},{"id":33,"kind":32,"name":"unsubscribe","url":"modules/_lib_index_.html#unsubscribe","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"lib/index\""},{"id":34,"kind":32,"name":"emit","url":"modules/_lib_index_.html#emit","classes":"tsd-kind-variable tsd-parent-kind-external-module","parent":"\"lib/index\""}]}; | ||
typedoc.search.data = {"kinds":{"64":"Function"},"rows":[{"id":0,"kind":64,"name":"subscribe","url":"globals.html#subscribe","classes":"tsd-kind-function"},{"id":1,"kind":64,"name":"unsubscribe","url":"globals.html#unsubscribe","classes":"tsd-kind-function"},{"id":2,"kind":64,"name":"emit","url":"globals.html#emit","classes":"tsd-kind-function"}]}; |
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
exports.emit = exports.unsubscribe = exports.subscribe = void 0; | ||
exports.subscribe = subscribe; | ||
exports.unsubscribe = unsubscribe; | ||
exports.emit = emit; | ||
@@ -28,8 +30,36 @@ var _ProxyBus = require("./ProxyBus"); | ||
var bus = getBus(); | ||
var subscribe = bus.subscribe.bind(bus); | ||
exports.subscribe = subscribe; | ||
var unsubscribe = bus.unsubscribe.bind(bus); | ||
exports.unsubscribe = unsubscribe; | ||
var emit = bus.emit.bind(bus); | ||
exports.emit = emit; | ||
/** | ||
* Register an event listener | ||
* | ||
* @param name name of the event | ||
* @param handler callback invoked for every matching event emitted on the bus | ||
*/ | ||
function subscribe(name, handler) { | ||
bus.subscribe(name, handler); | ||
} | ||
/** | ||
* Unregister a previously registered event listener | ||
* | ||
* Note: doesn't work with anonymous functions (closures). Use method of an object or store listener function in variable. | ||
* | ||
* @param name name of the event | ||
* @param handler callback passed to `subscribed` | ||
*/ | ||
function unsubscribe(name, handler) { | ||
bus.unsubscribe(name, handler); | ||
} | ||
/** | ||
* Emit an event | ||
* | ||
* @param name name of the event | ||
* @param event event payload | ||
*/ | ||
function emit(name, event) { | ||
bus.emit(name, event); | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -7,4 +7,24 @@ declare global { | ||
} | ||
export declare const subscribe: (name: string, handler: import("./EventHandler").EventHandler) => void; | ||
export declare const unsubscribe: (name: string, handler: import("./EventHandler").EventHandler) => void; | ||
export declare const emit: (name: string, event: import("./Event").Event) => void; | ||
/** | ||
* Register an event listener | ||
* | ||
* @param name name of the event | ||
* @param handler callback invoked for every matching event emitted on the bus | ||
*/ | ||
export declare function subscribe(name: string, handler: (string: any) => void): void; | ||
/** | ||
* Unregister a previously registered event listener | ||
* | ||
* Note: doesn't work with anonymous functions (closures). Use method of an object or store listener function in variable. | ||
* | ||
* @param name name of the event | ||
* @param handler callback passed to `subscribed` | ||
*/ | ||
export declare function unsubscribe(name: string, handler: (string: any) => void): void; | ||
/** | ||
* Emit an event | ||
* | ||
* @param name name of the event | ||
* @param event event payload | ||
*/ | ||
export declare function emit(name: string, event: object): void; |
@@ -23,2 +23,3 @@ export declare const name: string; | ||
export declare const dependencies: { | ||
"@types/semver": string; | ||
"core-js": string; | ||
@@ -25,0 +26,0 @@ "semver": string; |
@@ -22,3 +22,3 @@ "use strict"; | ||
name: "@nextcloud/event-bus", | ||
version: "1.0.1", | ||
version: "1.1.2", | ||
description: "", | ||
@@ -29,3 +29,3 @@ main: "dist/index.js", | ||
build: "babel ./lib --out-dir dist --extensions '.ts,.tsx' --source-maps && tsc --emitDeclarationOnly", | ||
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll", | ||
"build:doc": "typedoc --excludeNotExported --mode file --out dist/doc lib/index.ts && touch dist/doc/.nojekyll", | ||
"check-types": "tsc", | ||
@@ -45,4 +45,5 @@ dev: "babel ./lib --out-dir dist --extensions '.ts,.tsx' --watch", | ||
dependencies: { | ||
"core-js": "^3.1.4", | ||
semver: "^7.1.1" | ||
"@types/semver": "^6.2.0", | ||
"core-js": "^3.6.2", | ||
semver: "^6.3.0" | ||
}, | ||
@@ -59,3 +60,3 @@ devDependencies: { | ||
jest: "^24.9.0", | ||
typedoc: "^0.15.5", | ||
typedoc: "^0.15.7", | ||
typescript: "^3.6.3" | ||
@@ -62,0 +63,0 @@ }, |
@@ -34,3 +34,3 @@ "use strict"; | ||
name: "@nextcloud/event-bus", | ||
version: "1.0.1", | ||
version: "1.1.2", | ||
description: "", | ||
@@ -41,3 +41,3 @@ main: "dist/index.js", | ||
build: "babel ./lib --out-dir dist --extensions '.ts,.tsx' --source-maps && tsc --emitDeclarationOnly", | ||
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll", | ||
"build:doc": "typedoc --excludeNotExported --mode file --out dist/doc lib/index.ts && touch dist/doc/.nojekyll", | ||
"check-types": "tsc", | ||
@@ -57,4 +57,5 @@ dev: "babel ./lib --out-dir dist --extensions '.ts,.tsx' --watch", | ||
dependencies: { | ||
"core-js": "^3.1.4", | ||
semver: "^7.1.1" | ||
"@types/semver": "^6.2.0", | ||
"core-js": "^3.6.2", | ||
semver: "^6.3.0" | ||
}, | ||
@@ -71,3 +72,3 @@ devDependencies: { | ||
jest: "^24.9.0", | ||
typedoc: "^0.15.5", | ||
typedoc: "^0.15.7", | ||
typescript: "^3.6.3" | ||
@@ -74,0 +75,0 @@ }, |
@@ -28,4 +28,32 @@ import { EventBus } from "./EventBus" | ||
export const subscribe = bus.subscribe.bind(bus) | ||
export const unsubscribe = bus.unsubscribe.bind(bus) | ||
export const emit = bus.emit.bind(bus) | ||
/** | ||
* Register an event listener | ||
* | ||
* @param name name of the event | ||
* @param handler callback invoked for every matching event emitted on the bus | ||
*/ | ||
export function subscribe(name: string, handler: (string) => void): void { | ||
bus.subscribe(name, handler) | ||
} | ||
/** | ||
* Unregister a previously registered event listener | ||
* | ||
* Note: doesn't work with anonymous functions (closures). Use method of an object or store listener function in variable. | ||
* | ||
* @param name name of the event | ||
* @param handler callback passed to `subscribed` | ||
*/ | ||
export function unsubscribe(name: string, handler: (string) => void): void { | ||
bus.unsubscribe(name, handler) | ||
} | ||
/** | ||
* Emit an event | ||
* | ||
* @param name name of the event | ||
* @param event event payload | ||
*/ | ||
export function emit(name: string, event: object): void { | ||
bus.emit(name, event) | ||
} |
@@ -1,2 +0,2 @@ | ||
import semver from 'semver'; | ||
import semver from "semver"; | ||
@@ -3,0 +3,0 @@ import packageJson from "../package.json"; |
{ | ||
"name": "@nextcloud/event-bus", | ||
"version": "1.0.1", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"build": "babel ./lib --out-dir dist --extensions '.ts,.tsx' --source-maps && tsc --emitDeclarationOnly", | ||
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll", | ||
"build:doc": "typedoc --excludeNotExported --mode file --out dist/doc lib/index.ts && touch dist/doc/.nojekyll", | ||
"check-types": "tsc", | ||
@@ -27,4 +27,5 @@ "dev": "babel ./lib --out-dir dist --extensions '.ts,.tsx' --watch", | ||
"dependencies": { | ||
"core-js": "^3.1.4", | ||
"semver": "^7.1.1" | ||
"@types/semver": "^6.2.0", | ||
"core-js": "^3.6.2", | ||
"semver": "^6.3.0" | ||
}, | ||
@@ -41,3 +42,3 @@ "devDependencies": { | ||
"jest": "^24.9.0", | ||
"typedoc": "^0.15.5", | ||
"typedoc": "^0.15.7", | ||
"typescript": "^3.6.3" | ||
@@ -44,0 +45,0 @@ }, |
@@ -5,11 +5,17 @@ # @nextcloud/event-bus | ||
[![npm](https://img.shields.io/npm/v/@nextcloud/event-bus.svg)](https://www.npmjs.com/package/@nextcloud/event-bus) | ||
[![Documentation](https://img.shields.io/badge/Documentation-online-brightgreen)](https://nextcloud.github.io/nextcloud-event-bus/) | ||
A event bus to communicate between Nextcloud components | ||
A simple event bus to communicate between Nextcloud components. | ||
## Installation | ||
``` | ||
npm i -S @nextcloud/event-bus | ||
``` | ||
## Usage | ||
```js | ||
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' | ||
import { subscribe, unsubscribe, emit } from '@nextcloud/event-bus' | ||
const h = e => console.info(e) | ||
@@ -26,3 +32,2 @@ | ||
unsubscribe('b', h) | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2544
32
459006
3
56
+ Added@types/semver@^6.2.0
+ Added@types/semver@6.2.7(transitive)
+ Addedsemver@6.3.1(transitive)
- Removedsemver@7.7.1(transitive)
Updatedcore-js@^3.6.2
Updatedsemver@^6.3.0