@bdlite/observable
Advanced tools
+1
-1
@@ -14,3 +14,3 @@ import Observable from './observable' | ||
| const name = getName(channelName, useSession); | ||
| const bc = new BroadcastChannel(name); | ||
| const bc = new BroadcastChannel(name); // 主通道 | ||
@@ -17,0 +17,0 @@ const subCollection = new Map(); |
@@ -6,3 +6,3 @@ import Observable from './observable' | ||
| export function createObservableKit(initialData, options, { channelName = '' } = {}) { | ||
| export function createObservableKit(initialData, options, { channelName = '', channelOptions = {} } = {}) { | ||
| const observable = new Observable({ initialData, options: options || { relay: 1 } }) | ||
@@ -46,3 +46,3 @@ | ||
| if (channelName) { | ||
| broadcast(channelName)(observable) // 转跨页面广播模式 | ||
| broadcast(channelName, channelOptions)(observable) // 转跨页面广播模式 | ||
| } else { | ||
@@ -56,3 +56,3 @@ share()(observable) // 转发布订阅模式 | ||
| export function createSubChannelKit({ channelName = '' } = {}, options) { | ||
| export function createSubChannelKit({ channelName = '', channelOptions = {} } = {}, options) { | ||
| /** | ||
@@ -65,3 +65,3 @@ * @function subscribe | ||
| function subscribe(observer, beforeUnsubscribe) { | ||
| let subChannel = new SubChannel(channelName) // 这里不用const,为了能释放内存 | ||
| let subChannel = new SubChannel(channelName, channelOptions) // 这里不用const,为了能释放内存 | ||
| let callback = null | ||
@@ -68,0 +68,0 @@ |
+9
-5
| { | ||
| "name": "@bdlite/observable", | ||
| "version": "1.1.17", | ||
| "version": "1.1.18", | ||
| "description": "A publish-subscribe utility library designed with BroadcastChannel API", | ||
@@ -17,5 +17,8 @@ "keywords": [ | ||
| "scripts": { | ||
| "clean:es": "rimraf es", | ||
| "build": "rollup -c", | ||
| "build:tsc": "tsc && rollup -c", | ||
| "start": "rollup -c -w" | ||
| "start": "rollup -c -w", | ||
| "copy": "npm run clean:es && cp -r src es", | ||
| "prepublishOnly": "npm run copy" | ||
| }, | ||
@@ -34,2 +37,4 @@ "module": "es/index.js", | ||
| "devDependencies": { | ||
| "@rollup/plugin-babel": "6.0.4", | ||
| "@rollup/plugin-eslint": "9.0.5", | ||
| "@typescript-eslint/eslint-plugin": "^5.60.1", | ||
@@ -39,8 +44,7 @@ "@typescript-eslint/parser": "^5.60.1", | ||
| "husky": "^8.0.0", | ||
| "rollup": "^2.3.4", | ||
| "rollup-plugin-eslint": "^7.0.0", | ||
| "rollup": "4.9.5", | ||
| "rollup-plugin-typescript2": "^0.29.0", | ||
| "typescript": "^4.4.3" | ||
| }, | ||
| "gitHead": "23d7f21e98667663f215c9629f31fc45de37bf8a" | ||
| "gitHead": "fa855142350d724b5a3cfabed0b9c10c3cae558d" | ||
| } |
21271
1.13%9
12.5%