@logux/client
Advanced tools
Comparing version 0.3.4 to 0.4.0
@@ -50,3 +50,3 @@ /** | ||
unbind.push(client.log.on('add', function (action) { | ||
unbind.push(client.on('add', function (action) { | ||
if (action.type === 'logux/undo' && action.reason && !timeout) { | ||
@@ -53,0 +53,0 @@ blink() |
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.4 | ||
* Add `Client#on` method to unify API with `CrossTabClient`. | ||
* Add `preadd` event as alias to `client.log.on('preadd', cb)`. | ||
* Improve docs (by Paul Chavard). | ||
## 0.3.4 | ||
@@ -5,0 +10,0 @@ * Fix multiple resubscriptions. |
@@ -250,9 +250,4 @@ var isFirstOlder = require('@logux/core/is-first-older') | ||
this.emitter = new NanoEvents() | ||
this.on('add', listener) | ||
if (this.on) { | ||
this.on('add', listener) | ||
} else { | ||
log.on('add', listener) | ||
} | ||
this.tabPing = 60000 | ||
@@ -331,2 +326,3 @@ this.tabTimeout = 10 * this.tabPing | ||
if (disconnected) { | ||
disconnected = false | ||
for (var i in client.subscriptions) { | ||
@@ -339,3 +335,2 @@ var action = JSON.parse(i) | ||
} | ||
disconnected = false | ||
} else if (client.node.state === 'disconnected') { | ||
@@ -368,2 +363,24 @@ disconnected = true | ||
/** | ||
* Subscribe for synchronization events. It implements Nano Events API. | ||
* Supported events: | ||
* | ||
* * `preadd`: action is going to be added (in current tab). | ||
* * `add`: action has been added to log (by any tab). | ||
* * `clean`: action has been removed from log (by any tab). | ||
* | ||
* @param {"preadd"|"add"|"clean"} event The event name. | ||
* @param {listener} listener The listener function. | ||
* | ||
* @return {function} Unbind listener from event. | ||
* | ||
* @example | ||
* app.on('add', (action, meta) => { | ||
* dispatch(action) | ||
* }) | ||
*/ | ||
on: function on (event, listener) { | ||
return this.log.emitter.on(event, listener) | ||
}, | ||
/** | ||
* Disconnect and stop synchronization. | ||
@@ -370,0 +387,0 @@ * |
@@ -42,3 +42,3 @@ function block (e) { | ||
unbind.push(client.log.on('add', function (action, meta) { | ||
unbind.push(client.on('add', function (action, meta) { | ||
if (action.type === 'logux/subscribe') { | ||
@@ -45,0 +45,0 @@ return |
@@ -263,2 +263,3 @@ var merge = require('@logux/core/merge') | ||
* | ||
* * `preadd`: action is going to be added (in current tab). | ||
* * `add`: action has been added to log (by any tab). | ||
@@ -269,3 +270,3 @@ * * `clean`: action has been removed from log (by any tab). | ||
* | ||
* @param {"add"|"clean"|"role"|"state"} event The event name. | ||
* @param {"preadd"|"add"|"clean"|"role"|"state"} event The event name. | ||
* @param {listener} listener The listener function. | ||
@@ -281,3 +282,7 @@ * | ||
on: function on (event, listener) { | ||
return this.emitter.on(event, listener) | ||
if (event === 'preadd') { | ||
return this.log.emitter.on(event, listener) | ||
} else { | ||
return this.emitter.on(event, listener) | ||
} | ||
}, | ||
@@ -284,0 +289,0 @@ |
@@ -63,3 +63,3 @@ /** | ||
unbind.push(client.log.on('add', function (action) { | ||
unbind.push(client.on('add', function (action) { | ||
if (action.type === 'logux/undo' && action.reason) setError() | ||
@@ -66,0 +66,0 @@ })) |
{ | ||
"name": "@logux/client", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "Logux base components to build web client", | ||
@@ -16,7 +16,13 @@ "keywords": [ | ||
"dependencies": { | ||
"@logux/core": "^0.3.1", | ||
"@logux/core": "^0.3.2", | ||
"browser-supports-log-styles": "^1.1.7", | ||
"nanoevents": "^2.0.0", | ||
"nanoid": "^2.0.3" | ||
"nanoid": "^2.1.0" | ||
}, | ||
"eslintIgnore": [ | ||
"test/demo/build" | ||
], | ||
"sharec": { | ||
"version": "0.4.3" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # Logux Client [![Cult Of Martians][cult-img]][cult] | ||
* `IndexedStore` to store Logux log in `IndexedDB`. | ||
* `badge` widget to show Logux synchronization status in UI. | ||
* `badge()` widget to show Logux synchronization status in UI. | ||
* `status()` to write own UI to show Logux synchronization status in UI. | ||
@@ -48,5 +48,5 @@ * `attention()`, `confirm()`, `favicon()` to improve UX in Logux web app. | ||
import CrossTabClient from '@logux/client/cross-tab-client' | ||
import messages from 'logux-client/badge/en' | ||
import styles from 'logux-client/badge/default' | ||
import badge from 'logux-client/badge' | ||
import messages from '@logux/client/badge/en' | ||
import styles from '@logux/client/badge/default' | ||
import badge from '@logux/client/badge' | ||
import log from '@logux/client/log' | ||
@@ -53,0 +53,0 @@ |
@@ -118,6 +118,6 @@ /** | ||
* @param { | ||
* "synchronized"|"disconnected"|"wait"|"connecting"|"sending"| | ||
* "syncError"|"error"|"denied"|"protocolError" | ||
* } type Status type. | ||
* "synchronized"|"synchronizedAfterWait"|"disconnected"|"wait"|"error"| | ||
* "connecting"|"connectingAfterWait"|"syncError"|"denied"|"protocolError" | ||
* } type Status type. | ||
* @param {object|undefined} details Status details. | ||
*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61391
1686
Updated@logux/core@^0.3.2
Updatednanoid@^2.1.0