Socket
Socket
Sign inDemoInstall

mobservable

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobservable - npm Package Compare versions

Comparing version 1.0.6 to 1.0.8

6

CHANGELOG.md

@@ -0,4 +1,8 @@

# 1.0.7 / 1.0.8
Fixed inconsistency when using `transaction` and `@observer`, which sometimes caused stale values to be displayed.
# 1.0.6
Fix incompatibility issue with systemjs bundler
Fix incompatibility issue with systemjs bundler (see PR 52)

@@ -5,0 +9,0 @@ # 1.0.4/5

3

lib/core.js

@@ -13,3 +13,2 @@ /**

var observablemap_1 = require('./observablemap');
var scheduler_1 = require('./scheduler');
var dnode_2 = require('./dnode');

@@ -219,3 +218,3 @@ function observable(v, keyOrScope) {

function transaction(action) {
return scheduler_1.transaction(action);
return dnode_1.transaction(action);
}

@@ -222,0 +221,0 @@ exports.transaction = transaction;

export declare function checkIfStateIsBeingModifiedDuringView(context: IContextInfoStruct): void;
export declare function transaction<T>(action: () => T): T;
export declare enum NodeState {

@@ -3,0 +4,0 @@ STALE = 0,

@@ -14,2 +14,4 @@ /**

global.__mobservableViewStack = [];
var inTransaction = 0;
var changedValues = [];
var mobservableId = 0;

@@ -23,2 +25,20 @@ function checkIfStateIsBeingModifiedDuringView(context) {

exports.checkIfStateIsBeingModifiedDuringView = checkIfStateIsBeingModifiedDuringView;
function transaction(action) {
inTransaction += 1;
try {
return action();
}
finally {
if (--inTransaction === 0) {
console.log("TRANSEND");
var length_1 = changedValues.length;
for (var i = 0; i < length_1; i++)
changedValues[i].markReady(true);
changedValues.splice(0, length_1);
if (changedValues.length)
throw new Error("[mobservable] Illegal State, please file a bug report");
}
}
}
exports.transaction = transaction;
(function (NodeState) {

@@ -56,4 +76,2 @@ NodeState[NodeState["STALE"] = 0] = "STALE";

DataNode.prototype.markStale = function () {
if (this.state !== NodeState.READY)
return;
this.state = NodeState.STALE;

@@ -65,4 +83,8 @@ if (extras_1.transitionTracker)

DataNode.prototype.markReady = function (stateDidActuallyChange) {
if (this.state === NodeState.READY)
if (inTransaction > 0) {
changedValues.push(this);
if (!stateDidActuallyChange)
throw new Error("[mobservable] Illegal state; only data values can be readied while in transaction. Please file a bug with stacktrace.");
return;
}
this.state = NodeState.READY;

@@ -136,3 +158,2 @@ if (extras_1.transitionTracker)

ViewNode.prototype.notifyStateChange = function (observable, stateDidActuallyChange) {
var _this = this;
if (observable.state === NodeState.STALE) {

@@ -147,9 +168,7 @@ if (++this.dependencyStaleCount === 1)

this.state = NodeState.PENDING;
scheduler_1.schedule(function () {
if (_this.dependencyChangeCount > 0)
_this.computeNextState();
else
_this.markReady(false);
_this.dependencyChangeCount = 0;
});
if (this.dependencyChangeCount > 0)
this.computeNextState();
else
this.markReady(false);
this.dependencyChangeCount = 0;
}

@@ -236,3 +255,2 @@ }

var utils_1 = require('./utils');
var scheduler_1 = require('./scheduler');
//# sourceMappingURL=dnode.js.map

@@ -33,4 +33,4 @@ var __extends = (this && this.__extends) || function (d, b) {

this._value = this.makeReferenceValueReactive(newValue);
this.changeEvent.emit(this._value, oldValue);
this.markReady(true);
this.changeEvent.emit(this._value, oldValue);
}

@@ -37,0 +37,0 @@ return changed;

@@ -81,3 +81,3 @@ /**

ObservableView.prototype.toString = function () {
return "ComputedObservable[" + this.context.name + ":" + this._value + "] " + this.func.toString();
return "ComputedObservable[" + this.context.name + " (current value:'" + this._value + "')] " + this.func.toString();
};

@@ -84,0 +84,0 @@ return ObservableView;

{
"name": "mobservable",
"version": "1.0.6",
"version": "1.0.8",
"description": "Observable data. Reactive functions. Simple code.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc