Skip to content

Commit 89343c3

Browse files
committed
Merge branch 'features'
* features: Bug fixed when unsubscribe and resubscribe same object Allowing registrable Classes
2 parents 4258a67 + b520c5b commit 89343c3

File tree

16 files changed

+5975
-4230
lines changed

16 files changed

+5975
-4230
lines changed

examples/todomvc/package-lock.json

Lines changed: 0 additions & 4185 deletions
This file was deleted.

package-lock.json

Lines changed: 5879 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dop",
3-
"version": "0.26.2",
3+
"version": "0.27.0",
44
"main": "./dist/dop.nodejs.js",
55
"browser": "./dist/dop.js",
66
"unpkg": "./dist/dop.min.js",

src/api/isObjectRegistrable.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
21
dop.isObjectRegistrable = function(object) {
3-
if (object === null || typeof object !== "object") return false;
4-
var prototype = Object.getPrototypeOf(object);
5-
return prototype === Object.prototype || prototype === Array.prototype;
6-
};
7-
8-
//dop.isObjectRegistrable = function(object) {
9-
// var tof = dop.util.typeof(object);
10-
// return (tof === 'object' || tof == 'array');
11-
// };
12-
13-
// function Test(){}
14-
// console.log(isObjectRegistrable({}));
15-
// console.log(isObjectRegistrable([]));
16-
// console.log(isObjectRegistrable(new Test));
17-
// console.log(isObjectRegistrable(new Map));
18-
// console.log(isObjectRegistrable(new Date()));
19-
// console.log(isObjectRegistrable(null));
20-
// console.log(isObjectRegistrable(Symbol('')));
21-
// console.log(isObjectRegistrable(function(){}));
22-
// console.log(isObjectRegistrable(1));
23-
// console.log(isObjectRegistrable("s"));
24-
// console.log(isObjectRegistrable(true));
25-
// console.log(isObjectRegistrable(/a/));
2+
return isObject(object);
3+
};

src/api/isPojoObject.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
dop.isPojoObject = function(object) {
2+
if (object === null || typeof object !== "object") return false;
3+
var prototype = Object.getPrototypeOf(object);
4+
return prototype === Object.prototype || prototype === Array.prototype;
5+
};
6+
7+
8+
// dop.isPojoObject = function(object) {
9+
// var tof = dop.util.typeof(object);
10+
// return (tof === 'object' || tof == 'array');
11+
// };
12+
13+
// function Test(){}
14+
// console.log(dop.isPojoObject({}));
15+
// console.log(dop.isPojoObject([]));
16+
// console.log(dop.isPojoObject(new Error));
17+
// console.log(dop.isPojoObject(new Date()));
18+
// console.log(dop.isPojoObject(null));
19+
// console.log(dop.isPojoObject(Symbol('')));
20+
// console.log(dop.isPojoObject(function(){}));
21+
// console.log(dop.isPojoObject(1));
22+
// console.log(dop.isPojoObject("s"));
23+
// console.log(dop.isPojoObject(true));
24+
// console.log(dop.isPojoObject(/a/));

src/api/register.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
dop.register = function(object) {
3-
dop.util.invariant(dop.isObjectRegistrable(object) && !isArray(object), 'dop.register needs a regular plain object as first parameter');
3+
dop.util.invariant(dop.isObjectRegistrable(object) && !isArray(object), 'dop.register needs an object or an array as first parameter');
44
return (dop.isRegistered(object)) ?
55
dop.getObjectProxy(object)
66
:

src/core/mutators/set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dop.core.set = function(object, property, value, options) {
2525
// property = Number(property);
2626

2727
// object or array
28-
if (options.deep && dop.isObjectRegistrable(value) && !(dop.isRegistered(value) && dop.getObjectParent(value) === objectProxy))
28+
if (options.deep && dop.isPojoObject(value) && !(dop.isRegistered(value) && dop.getObjectParent(value) === objectProxy))
2929
objectTarget[property] = dop.core.configureObject(value, property, objectProxy);
3030
// computed value
3131
else if (isFunction(value) && value._name==dop.cons.COMPUTED_FUNCTION)

src/core/mutators/splice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dop.core.splice = function(array, args) {
4545
// We must register new objects
4646
for (;index<argslength; ++index, ++start) {
4747
item = args[index];
48-
if (dop.isObjectRegistrable(item))
48+
if (dop.isPojoObject(item))
4949
objectTarget[start] = dop.core.configureObject(
5050
item,
5151
start,

src/core/objects/configureObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ dop.core.configureObject = function(object, propertyParent, parent) {
7474
else if (is_function && value._name==dop.cons.COMPUTED_FUNCTION)
7575
object_target[property] = value(object_proxy, property, false, undefined);
7676
// object or array
77-
else if (dop.isObjectRegistrable(value))
77+
else if (dop.isPojoObject(value))
7878
object_target[property] = dop.core.configureObject(value, property, object_proxy);
7979
}
8080

src/protocol/_onunsubscribe.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ dop.protocol._onunsubscribe = function(node, request_id, request, response) {
1616
if (roles.subscriber === 0)
1717
object_data.nodes_total -= 1;
1818

19-
if (object_data.nodes_total === 0)
19+
if (object_data.nodes_total === 0) {
20+
// Deleting object
2021
delete dop.data.object[object_id];
22+
// Deleting reference of the object in the node instance
23+
for (var id in node.owner) {
24+
if (node.owner[id] === object_id) {
25+
delete node.owner[id];
26+
break;
27+
}
28+
}
29+
}
2130

2231
request.promise.resolve();
2332
}

0 commit comments

Comments
 (0)