From 9939679f9b644d379697826286f0cd628356febe Mon Sep 17 00:00:00 2001
From: josdejong
Date: Tue, 11 Feb 2014 11:55:23 +0100
Subject: [PATCH] Renamed DataSet functions `subscribe` and `unsubscribe` to
`on` and `off`
---
HISTORY.md | 8 +++--
docs/dataset.html | 30 +++++++++---------
docs/dataview.html | 8 ++---
examples/timeline/06_event_listeners.html | 17 ++++++++--
src/DataSet.js | 10 ++++--
src/DataView.js | 12 ++++---
src/graph/Graph.js | 4 +--
src/timeline/component/GroupSet.js | 2 +-
src/timeline/component/ItemSet.js | 2 +-
test/dataset.js | 1 +
test/dataview.js | 4 +--
test/eventbus.js | 38 -----------------------
12 files changed, 62 insertions(+), 74 deletions(-)
delete mode 100644 test/eventbus.js
diff --git a/HISTORY.md b/HISTORY.md
index 775135e1..63236e0b 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -6,9 +6,13 @@ http://visjs.org
### Timeline
-- items can be dragged and removed.
+- Items can be dragged and removed.
- Implemented options `selectable`, `editable`.
-- added events when dragging the custom time bar.
+- Added events when dragging the custom time bar.
+
+### DataSet
+
+- Renamed functions `subscribe` and `unsubscribe` to `on` and `off` respectively.
## 2014-01-31, version 0.4.0
diff --git a/docs/dataset.html b/docs/dataset.html
index e6e8310b..cbb2ec8f 100644
--- a/docs/dataset.html
+++ b/docs/dataset.html
@@ -62,8 +62,8 @@ data.add([
]);
// subscribe to any change in the DataSet
-data.subscribe('*', function (event, params, senderId) {
- console.log('event', event, params);
+data.on('*', function (event, properties, senderId) {
+ console.log('event', event, properties);
});
// update an existing item
@@ -545,8 +545,8 @@ var items = data.get({
One can subscribe on changes in a DataSet.
- A subscription can be created using the method subscribe
,
- and removed with unsubscribe
.
+ A subscription can be created using the method on
,
+ and removed with off
.
@@ -554,8 +554,8 @@ var items = data.get({
var data = new vis.DataSet();
// subscribe to any change in the DataSet
-data.subscribe('*', function (event, params, senderId) {
- console.log('event:', event, 'params:', params, 'senderId:', senderId);
+data.on('*', function (event, properties, senderId) {
+ console.log('event:', event, 'properties:', properties, 'senderId:', senderId);
});
// add an item
@@ -565,14 +565,14 @@ data.remove(1); // triggers an 'remove' event
-Subscribe
+On
Subscribe to an event.
Syntax:
-DataSet.subscribe(event, callback)
+DataSet.on(event, callback)
Where:
@@ -587,17 +587,17 @@ Where:
-Unsubscribe
+Off
Unsubscribe from an event.
Syntax:
-DataSet.unsubscribe(event, callback)
+DataSet.off(event, callback)
Where event
and callback
correspond with the
-parameters used to subscribe to the event.
+parameters used to subscribe to the event.
Events
@@ -650,7 +650,7 @@ parameters used to subscribe to the event.
-function (event, params, senderId) {
+function (event, properties, senderId) {
// handle the event
});
@@ -674,13 +674,13 @@ function (event, params, senderId) {
- params |
+ properties |
Object | null |
- Optional parameters providing more information on the event.
+ Optional properties providing more information on the event.
In case of the events add ,
update , and remove ,
- params is always an object containing a property
+ properties is always an object containing a property
items, which contains an array with the ids of the affected
items.
|
diff --git a/docs/dataview.html b/docs/dataview.html
index 1698ffb1..a1fd350f 100644
--- a/docs/dataview.html
+++ b/docs/dataview.html
@@ -63,8 +63,8 @@ var view = new vis.DataView(data, {
});
// subscribe to any change in the DataView
-view.subscribe('*', function (event, params, senderId) {
- console.log('event', event, params);
+view.on('*', function (event, properties, senderId) {
+ console.log('event', event, properties);
});
// update an item in the data set
@@ -201,8 +201,8 @@ var view = new vis.DataView({
});
// subscribe to any change in the DataView
-view.subscribe('*', function (event, params, senderId) {
- console.log('event:', event, 'params:', params, 'senderId:', senderId);
+view.on('*', function (event, properties, senderId) {
+ console.log('event:', event, 'properties:', properties, 'senderId:', senderId);
});
// add, update, and remove data in the DataSet...
diff --git a/examples/timeline/06_event_listeners.html b/examples/timeline/06_event_listeners.html
index 8ea72e1b..e488e930 100644
--- a/examples/timeline/06_event_listeners.html
+++ b/examples/timeline/06_event_listeners.html
@@ -18,15 +18,22 @@