sync speedup
This commit is contained in:
		
							parent
							
								
									089ae137dc
								
							
						
					
					
						commit
						a637633a1c
					
				@ -2,7 +2,7 @@
 | 
			
		||||
var createIwcConnector;
 | 
			
		||||
 | 
			
		||||
createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
  var IwcConnector, duiClient, get_HB_intent, init, iwcHandler, received_HB, send_get_HB_intent;
 | 
			
		||||
  var IwcConnector, duiClient, init, iwcHandler, received_HB;
 | 
			
		||||
  iwcHandler = {};
 | 
			
		||||
  duiClient = new DUIClient();
 | 
			
		||||
  duiClient.connect(function(intent) {
 | 
			
		||||
@ -26,22 +26,31 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
      this.iwcHandler = iwcHandler;
 | 
			
		||||
      send_ = (function(_this) {
 | 
			
		||||
        return function(o) {
 | 
			
		||||
          return _this.send(o);
 | 
			
		||||
          if (Object.getOwnPropertyNames(_this.initialized).length !== 0) {
 | 
			
		||||
            return _this.send(o);
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      this.execution_listener.push(send_);
 | 
			
		||||
      this.initialized = {};
 | 
			
		||||
      receiveHB = (function(_this) {
 | 
			
		||||
        return function(json) {
 | 
			
		||||
          HB = json != null ? json.extras.HB : void 0;
 | 
			
		||||
          return _this.engine.applyOpsCheckDouble(HB);
 | 
			
		||||
          var him;
 | 
			
		||||
          HB = json.extras.HB;
 | 
			
		||||
          him = json.extras.user;
 | 
			
		||||
          _this.engine.applyOpsCheckDouble(HB);
 | 
			
		||||
          return _this.initialized[him] = true;
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      iwcHandler["Yatta_push_HB_element"] = [receiveHB];
 | 
			
		||||
      this.sendIwcIntent("Yatta_get_HB_element", {});
 | 
			
		||||
      receive_ = (function(_this) {
 | 
			
		||||
        return function(intent) {
 | 
			
		||||
          var o;
 | 
			
		||||
          o = intent.extras;
 | 
			
		||||
          return _this.receive(o);
 | 
			
		||||
          if (_this.initialized[o.uid.creator] != null) {
 | 
			
		||||
            return _this.receive(o);
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      this.iwcHandler["Yatta_new_operation"] = [receive_];
 | 
			
		||||
@ -52,7 +61,8 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
        return function() {
 | 
			
		||||
          var json;
 | 
			
		||||
          json = {
 | 
			
		||||
            HB: _this.yatta.getHistoryBuffer()._encode()
 | 
			
		||||
            HB: _this.yatta.getHistoryBuffer()._encode(),
 | 
			
		||||
            user: _this.yatta.getUserId()
 | 
			
		||||
          };
 | 
			
		||||
          return _this.sendIwcIntent("Yatta_push_HB_element", json);
 | 
			
		||||
        };
 | 
			
		||||
@ -88,20 +98,8 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
    return IwcConnector;
 | 
			
		||||
 | 
			
		||||
  })();
 | 
			
		||||
  get_HB_intent = {
 | 
			
		||||
    action: "Yatta_get_HB_element",
 | 
			
		||||
    component: "",
 | 
			
		||||
    data: "",
 | 
			
		||||
    dataType: "",
 | 
			
		||||
    flags: ["PUBLISH_GLOBAL"],
 | 
			
		||||
    extras: {}
 | 
			
		||||
  };
 | 
			
		||||
  send_get_HB_intent = function() {
 | 
			
		||||
    return duiClient.sendIntent(get_HB_intent);
 | 
			
		||||
  };
 | 
			
		||||
  init = function() {
 | 
			
		||||
    var proposed_user_id;
 | 
			
		||||
    setTimeout(send_get_HB_intent, 1000);
 | 
			
		||||
    proposed_user_id = null;
 | 
			
		||||
    if (initial_user_id != null) {
 | 
			
		||||
      proposed_user_id = initial_user_id;
 | 
			
		||||
@ -110,7 +108,7 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
    }
 | 
			
		||||
    return callback(IwcConnector, proposed_user_id);
 | 
			
		||||
  };
 | 
			
		||||
  setTimeout(init, 1000.);
 | 
			
		||||
  setTimeout(init, 5000);
 | 
			
		||||
  return void 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								build/browser/Connectors/IwcConnector.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								build/browser/Connectors/IwcConnector.min.js
									
									
									
									
										vendored
									
									
								
							@ -1 +1 @@
 | 
			
		||||
!function t(n,e,r){function i(u,a){if(!e[u]){if(!n[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=e[u]={exports:{}};n[u][0].call(s.exports,function(t){var e=n[u][1][t];return i(e?e:t)},s,s.exports,t,n,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,o,u,a,c;return u={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=u[t.action])?n.map(function(n){return setTimeout(function(){return n(t)},0)}):void 0}),r.initOK(),a=null,e=function(){function t(t,n,e,i){var o,c,s,f;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=u,f=function(t){return function(n){return t.send(n)}}(this),this.execution_listener.push(f),o=function(t){return function(e){return n=null!=e?e.extras.HB:void 0,t.engine.applyOpsCheckDouble(n)}}(this),u.Yatta_push_HB_element=[o],c=function(t){return function(n){var e;return e=n.extras,t.receive(e)}}(this),this.iwcHandler.Yatta_new_operation=[c],null!=a&&this.engine.applyOpsCheckDouble(a),s=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[s]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n},this.duiClient.sendIntent(e)},t}(),i={action:"Yatta_get_HB_element",component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:{}},c=function(){return r.sendIntent(i)},o=function(){var r;return setTimeout(c,1e3),r=null,r=null!=n?n:Math.floor(1e6*Math.random()),t(e,r)},void setTimeout(o,1e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=e)},{}]},{},[1]);
 | 
			
		||||
!function t(e,n,i){function r(u,a){if(!n[u]){if(!e[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=n[u]={exports:{}};e[u][0].call(c.exports,function(t){var n=e[u][1][t];return r(n?n:t)},c,c.exports,t,e,n,i)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<i.length;u++)r(i[u]);return r}({1:[function(t,e){var n;n=function(t,e){var n,i,r,o,u;return o={},i=new DUIClient,i.connect(function(t){var e;return null!=(e=o[t.action])?e.map(function(e){return setTimeout(function(){return e(t)},0)}):void 0}),i.initOK(),u=null,n=function(){function t(t,e,n,r){var a,s,c,l;this.engine=t,this.HB=e,this.execution_listener=n,this.yatta=r,this.duiClient=i,this.iwcHandler=o,l=function(t){return function(e){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(e):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(n){var i;return e=n.extras.HB,i=n.extras.user,t.engine.applyOpsCheckDouble(e),t.initialized[i]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(e){var n;return n=e.extras,null!=t.initialized[n.uid.creator]?t.receive(n):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(){var e;return e={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,e){var n;return n={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:e},this.duiClient.sendIntent(n)},t}(),r=function(){var i;return i=null,i=null!=e?e:Math.floor(1e6*Math.random()),t(n,i)},void setTimeout(r,5e3)},e.exports=n,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=n)},{}]},{},[1]);
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
var createIwcConnector;
 | 
			
		||||
 | 
			
		||||
createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
  var IwcConnector, duiClient, get_HB_intent, init, iwcHandler, received_HB, send_get_HB_intent;
 | 
			
		||||
  var IwcConnector, duiClient, init, iwcHandler, received_HB;
 | 
			
		||||
  iwcHandler = {};
 | 
			
		||||
  duiClient = new DUIClient();
 | 
			
		||||
  duiClient.connect(function(intent) {
 | 
			
		||||
@ -26,22 +26,31 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
      this.iwcHandler = iwcHandler;
 | 
			
		||||
      send_ = (function(_this) {
 | 
			
		||||
        return function(o) {
 | 
			
		||||
          return _this.send(o);
 | 
			
		||||
          if (Object.getOwnPropertyNames(_this.initialized).length !== 0) {
 | 
			
		||||
            return _this.send(o);
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      this.execution_listener.push(send_);
 | 
			
		||||
      this.initialized = {};
 | 
			
		||||
      receiveHB = (function(_this) {
 | 
			
		||||
        return function(json) {
 | 
			
		||||
          HB = json != null ? json.extras.HB : void 0;
 | 
			
		||||
          return _this.engine.applyOpsCheckDouble(HB);
 | 
			
		||||
          var him;
 | 
			
		||||
          HB = json.extras.HB;
 | 
			
		||||
          him = json.extras.user;
 | 
			
		||||
          _this.engine.applyOpsCheckDouble(HB);
 | 
			
		||||
          return _this.initialized[him] = true;
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      iwcHandler["Yatta_push_HB_element"] = [receiveHB];
 | 
			
		||||
      this.sendIwcIntent("Yatta_get_HB_element", {});
 | 
			
		||||
      receive_ = (function(_this) {
 | 
			
		||||
        return function(intent) {
 | 
			
		||||
          var o;
 | 
			
		||||
          o = intent.extras;
 | 
			
		||||
          return _this.receive(o);
 | 
			
		||||
          if (_this.initialized[o.uid.creator] != null) {
 | 
			
		||||
            return _this.receive(o);
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
      })(this);
 | 
			
		||||
      this.iwcHandler["Yatta_new_operation"] = [receive_];
 | 
			
		||||
@ -52,7 +61,8 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
        return function() {
 | 
			
		||||
          var json;
 | 
			
		||||
          json = {
 | 
			
		||||
            HB: _this.yatta.getHistoryBuffer()._encode()
 | 
			
		||||
            HB: _this.yatta.getHistoryBuffer()._encode(),
 | 
			
		||||
            user: _this.yatta.getUserId()
 | 
			
		||||
          };
 | 
			
		||||
          return _this.sendIwcIntent("Yatta_push_HB_element", json);
 | 
			
		||||
        };
 | 
			
		||||
@ -88,20 +98,8 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
    return IwcConnector;
 | 
			
		||||
 | 
			
		||||
  })();
 | 
			
		||||
  get_HB_intent = {
 | 
			
		||||
    action: "Yatta_get_HB_element",
 | 
			
		||||
    component: "",
 | 
			
		||||
    data: "",
 | 
			
		||||
    dataType: "",
 | 
			
		||||
    flags: ["PUBLISH_GLOBAL"],
 | 
			
		||||
    extras: {}
 | 
			
		||||
  };
 | 
			
		||||
  send_get_HB_intent = function() {
 | 
			
		||||
    return duiClient.sendIntent(get_HB_intent);
 | 
			
		||||
  };
 | 
			
		||||
  init = function() {
 | 
			
		||||
    var proposed_user_id;
 | 
			
		||||
    setTimeout(send_get_HB_intent, 1000);
 | 
			
		||||
    proposed_user_id = null;
 | 
			
		||||
    if (initial_user_id != null) {
 | 
			
		||||
      proposed_user_id = initial_user_id;
 | 
			
		||||
@ -110,7 +108,7 @@ createIwcConnector = function(callback, initial_user_id) {
 | 
			
		||||
    }
 | 
			
		||||
    return callback(IwcConnector, proposed_user_id);
 | 
			
		||||
  };
 | 
			
		||||
  setTimeout(init, 1000.);
 | 
			
		||||
  setTimeout(init, 5000);
 | 
			
		||||
  return void 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								build/browser/index.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								build/browser/index.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -1,2 +1,2 @@
 | 
			
		||||
(function(){var t;t=function(t,n){var e,i,r,o,u,a,s;return u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])?n.map(function(n){return setTimeout(function(){return n(t)},0)}):void 0}),i.initOK(),a=null,e=function(){function t(t,n,e,r){var o,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,l=function(t){return function(n){return t.send(n)}}(this),this.execution_listener.push(l),o=function(t){return function(e){return n=null!=e?e.extras.HB:void 0,t.engine.applyOpsCheckDouble(n)}}(this),u.Yatta_push_HB_element=[o],s=function(t){return function(n){var e;return e=n.extras,t.receive(e)}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=a&&this.engine.applyOpsCheckDouble(a),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n},this.duiClient.sendIntent(e)},t}(),r={action:"Yatta_get_HB_element",component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:{}},s=function(){return i.sendIntent(r)},o=function(){var i;return setTimeout(s,1e3),i=null,i=null!=n?n:Math.floor(1e6*Math.random()),t(e,i)},void setTimeout(o,1e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=t)}).call(this);
 | 
			
		||||
(function(){var t;t=function(t,e){var n,i,r,o,u;return o={},i=new DUIClient,i.connect(function(t){var e;return null!=(e=o[t.action])?e.map(function(e){return setTimeout(function(){return e(t)},0)}):void 0}),i.initOK(),u=null,n=function(){function t(t,e,n,r){var a,s,c,l;this.engine=t,this.HB=e,this.execution_listener=n,this.yatta=r,this.duiClient=i,this.iwcHandler=o,l=function(t){return function(e){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(e):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(n){var i;return e=n.extras.HB,i=n.extras.user,t.engine.applyOpsCheckDouble(e),t.initialized[i]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(e){var n;return n=e.extras,null!=t.initialized[n.uid.creator]?t.receive(n):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(){var e;return e={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,e){var n;return n={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:e},this.duiClient.sendIntent(n)},t}(),r=function(){var i;return i=null,i=null!=e?e:Math.floor(1e6*Math.random()),t(n,i)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=t)}).call(this);
 | 
			
		||||
//# sourceMappingURL=../Connectors/IwcConnector.js.map
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -54,123 +54,9 @@ A string property can be either mutable or immutable.
 | 
			
		||||
      yatta.val('mutable_string').insertText(2,"XXX"); // position, string
 | 
			
		||||
      yatta.val('mutable_string').deleteText(0,1); // position, deletion length
 | 
			
		||||
      console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
You can omit the mutable - parameter. In that case the default will be used.
 | 
			
		||||
Initially the default is 'mutable'. You can set it like this:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.setMutableDefault('mutable');
 | 
			
		||||
      // or
 | 
			
		||||
      yatta.setMutableDefault('immutable');
 | 
			
		||||
 | 
			
		||||
      yatta.val('new_string', "string");
 | 
			
		||||
      console.log(yatta.val('new_string') === "string"); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
yatta is chainable:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('a', 4).val('b',5);
 | 
			
		||||
      console.log(yatta.val('a') === 4); // true
 | 
			
		||||
      console.log(yatta.val('b') === 5); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
You can alse set objects.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
 | 
			
		||||
      console.log(yatta.val('object').val('c').val('d') === 5); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Lists are always immutable.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('list', [1,2,3]);
 | 
			
		||||
      console.log(yatta.val('list')[2] === 3); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
But there is a much more convenient way!
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      console.log(yatta.value.list[2] === 3) // true
 | 
			
		||||
      yatta.value.list = [3,4,5]
 | 
			
		||||
      console.log(yatta.val('list')[2] === 5) // true
 | 
			
		||||
      yatta.value.object = {c : 4}
 | 
			
		||||
      console.log(yatta.value.object.c === 4) // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
The downside is that you are only allowed to overwrite existing properties.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value.newProperty = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
So, how do we create new properties?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : "Awesome"}
 | 
			
		||||
      console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
This is stupid! I don't want to overwrite all my existing properties!
 | 
			
		||||
Very well.. The solution is that we merge yatta.value with the new assignment.
 | 
			
		||||
For example: assuming we want to overwrite yatta.value with some object o.
 | 
			
		||||
Then these two rules apply:
 | 
			
		||||
* The result has all properties of o
 | 
			
		||||
* The result has all properties of yatta.value if they don't occur under the same property-name in o
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : {Awesome : true }}
 | 
			
		||||
      console.log(yatta.value.list[2] === 5) // true, old value list still exists.
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Consider this case.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : { x : 4} }
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Did you notice that you always set immutable objects if you set properties like this?
 | 
			
		||||
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
 | 
			
		||||
 | 
			
		||||
One last thing. You are only allowed to set properties like this `yatta.value = o`.
 | 
			
		||||
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      w = yatta.value.newProperty
 | 
			
		||||
      w = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
window.onload = init
 | 
			
		||||
 | 
			
		||||
@ -42,89 +42,8 @@ function init(){
 | 
			
		||||
      yatta.val('mutable_string').deleteText(0,1); // position, deletion length
 | 
			
		||||
      console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       You can omit the mutable - parameter. In that case the default will be used.
 | 
			
		||||
       Initially the default is 'mutable'. You can set it like this:
 | 
			
		||||
       */
 | 
			
		||||
      yatta.setMutableDefault('mutable');
 | 
			
		||||
      // or
 | 
			
		||||
      yatta.setMutableDefault('immutable');
 | 
			
		||||
 | 
			
		||||
      yatta.val('new_string', "string");
 | 
			
		||||
      console.log(yatta.val('new_string') === "string"); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       yatta is chainable:
 | 
			
		||||
       */
 | 
			
		||||
      yatta.val('a', 4).val('b',5);
 | 
			
		||||
      console.log(yatta.val('a') === 4); // true
 | 
			
		||||
      console.log(yatta.val('b') === 5); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       You can alse set objects.
 | 
			
		||||
       */
 | 
			
		||||
      yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
 | 
			
		||||
      console.log(yatta.val('object').val('c').val('d') === 5); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Lists are always immutable.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.val('list', [1,2,3]);
 | 
			
		||||
      console.log(yatta.val('list')[2] === 3); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       But there is a much more convenient way!
 | 
			
		||||
      */
 | 
			
		||||
      console.log(yatta.value.list[2] === 3) // true
 | 
			
		||||
      yatta.value.list = [3,4,5]
 | 
			
		||||
      console.log(yatta.val('list')[2] === 5) // true
 | 
			
		||||
      yatta.value.object = {c : 4}
 | 
			
		||||
      console.log(yatta.value.object.c === 4) // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       The downside is that you are only allowed to overwrite existing properties.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value.newProperty = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       So, how do we create new properties?
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : "Awesome"}
 | 
			
		||||
      console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       This is stupid! I don't want to overwrite all my existing properties!
 | 
			
		||||
       Very well.. The solution is that we merge yatta.value with the new assignment.
 | 
			
		||||
       For example: assuming we want to overwrite yatta.value with some object o.
 | 
			
		||||
       Then these two rules apply:
 | 
			
		||||
       * The result has all properties of o
 | 
			
		||||
       * The result has all properties of yatta.value if they don't occur under the same property-name in o
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : {Awesome : true }}
 | 
			
		||||
      console.log(yatta.value.list[2] === 5) // true, old value list still exists.
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Consider this case.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : { x : 4} }
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Did you notice that you always set immutable objects if you set properties like this?
 | 
			
		||||
       Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
 | 
			
		||||
 | 
			
		||||
       One last thing. You are only allowed to set properties like this `yatta.value = o`.
 | 
			
		||||
       Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
 | 
			
		||||
      */
 | 
			
		||||
      w = yatta.value.newProperty
 | 
			
		||||
      w = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
 | 
			
		||||
      */
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
window.onload = init
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								examples/Json/IwcJson.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								examples/Json/IwcJson.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<Module>
 | 
			
		||||
 <ModulePrefs title="Video upload" description="Upload videos in Sevianno" author="Kevin Jahns, Chair of Computer Science 5, RWTH Aachen University, Germany" author_email="jahns@dbis.rwth-aachen.de"  scrolling="true">
 | 
			
		||||
        <Require feature="dynamic-height"/>
 | 
			
		||||
 | 
			
		||||
</ModulePrefs>
 | 
			
		||||
 | 
			
		||||
  <Content type="html"><![CDATA[
 | 
			
		||||
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
 | 
			
		||||
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
 | 
			
		||||
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
 | 
			
		||||
<script src="./index.js"></script>
 | 
			
		||||
<h1> Collaborative Json Widget </h1>
 | 
			
		||||
  ]]></Content>
 | 
			
		||||
</Module>
 | 
			
		||||
							
								
								
									
										177
									
								
								examples/Json/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								examples/Json/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,177 @@
 | 
			
		||||
## IWC + JSON Example
 | 
			
		||||
Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets.
 | 
			
		||||
First you have to include the following libraries in your widget file:
 | 
			
		||||
```
 | 
			
		||||
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
 | 
			
		||||
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
 | 
			
		||||
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
 | 
			
		||||
<script src="./index.js"></script>
 | 
			
		||||
```
 | 
			
		||||
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
function init(){
 | 
			
		||||
    createIwcConnector(function(Connector, user_id){
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
yatta is the shared json object. If you change something on this object,
 | 
			
		||||
it will be instantly shared with all the other collaborators.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta = new JsonYatta(user_id, Connector);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Add a integer-property like this
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('x', 7);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Get the value of property x like this
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      console.log(yatta.val('x') === 7); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
A string property can be either mutable or immutable.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('mutable_string', "text", "mutable");
 | 
			
		||||
      yatta.val('immutable_string', "text", "immutable");
 | 
			
		||||
 | 
			
		||||
      console.log(yatta.val('immutable_string') === "text"); // true
 | 
			
		||||
      yatta.val('mutable_string').insertText(2,"XXX"); // position, string
 | 
			
		||||
      yatta.val('mutable_string').deleteText(0,1); // position, deletion length
 | 
			
		||||
      console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
You can omit the mutable - parameter. In that case the default will be used.
 | 
			
		||||
Initially the default is 'mutable'. You can set it like this:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.setMutableDefault('mutable');
 | 
			
		||||
      // or
 | 
			
		||||
      yatta.setMutableDefault('immutable');
 | 
			
		||||
 | 
			
		||||
      yatta.val('new_string', "string");
 | 
			
		||||
      console.log(yatta.val('new_string') === "string"); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
yatta is chainable:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('a', 4).val('b',5);
 | 
			
		||||
      console.log(yatta.val('a') === 4); // true
 | 
			
		||||
      console.log(yatta.val('b') === 5); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
You can alse set objects.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
 | 
			
		||||
      console.log(yatta.val('object').val('c').val('d') === 5); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Lists are always immutable.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.val('list', [1,2,3]);
 | 
			
		||||
      console.log(yatta.val('list')[2] === 3); // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
But there is a much more convenient way!
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      console.log(yatta.value.list[2] === 3) // true
 | 
			
		||||
      yatta.value.list = [3,4,5]
 | 
			
		||||
      console.log(yatta.val('list')[2] === 5) // true
 | 
			
		||||
      yatta.value.object = {c : 4}
 | 
			
		||||
      console.log(yatta.value.object.c === 4) // true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
The downside is that you are only allowed to overwrite existing properties.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value.newProperty = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
So, how do we create new properties?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : "Awesome"}
 | 
			
		||||
      console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
This is stupid! I don't want to overwrite all my existing properties!
 | 
			
		||||
Very well.. The solution is that we merge yatta.value with the new assignment.
 | 
			
		||||
For example: assuming we want to overwrite yatta.value with some object o.
 | 
			
		||||
Then these two rules apply:
 | 
			
		||||
* The result has all properties of o
 | 
			
		||||
* The result has all properties of yatta.value if they don't occur under the same property-name in o
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : {Awesome : true }}
 | 
			
		||||
      console.log(yatta.value.list[2] === 5) // true, old value list still exists.
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Consider this case.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      yatta.value = {newProperty : { x : 4} }
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Did you notice that you always set immutable objects if you set properties like this?
 | 
			
		||||
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
 | 
			
		||||
 | 
			
		||||
One last thing. You are only allowed to set properties like this `yatta.value = o`.
 | 
			
		||||
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
      w = yatta.value.newProperty
 | 
			
		||||
      w = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
window.onload = init
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										130
									
								
								examples/Json/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								examples/Json/index.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,130 @@
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 ## IWC + JSON Example
 | 
			
		||||
 Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets.
 | 
			
		||||
 First you have to include the following libraries in your widget file:
 | 
			
		||||
 ```
 | 
			
		||||
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
 | 
			
		||||
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
 | 
			
		||||
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
 | 
			
		||||
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
 | 
			
		||||
<script src="./index.js"></script>
 | 
			
		||||
 ```
 | 
			
		||||
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
 | 
			
		||||
 */
 | 
			
		||||
function init(){
 | 
			
		||||
    createIwcConnector(function(Connector, user_id){
 | 
			
		||||
      /**
 | 
			
		||||
       yatta is the shared json object. If you change something on this object,
 | 
			
		||||
       it will be instantly shared with all the other collaborators.
 | 
			
		||||
      */
 | 
			
		||||
      yatta = new JsonYatta(user_id, Connector);
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Add a integer-property like this
 | 
			
		||||
      */
 | 
			
		||||
      yatta.val('x', 7);
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Get the value of property x like this
 | 
			
		||||
      */
 | 
			
		||||
      console.log(yatta.val('x') === 7); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       A string property can be either mutable or immutable.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.val('mutable_string', "text", "mutable");
 | 
			
		||||
      yatta.val('immutable_string', "text", "immutable");
 | 
			
		||||
 | 
			
		||||
      console.log(yatta.val('immutable_string') === "text"); // true
 | 
			
		||||
      yatta.val('mutable_string').insertText(2,"XXX"); // position, string
 | 
			
		||||
      yatta.val('mutable_string').deleteText(0,1); // position, deletion length
 | 
			
		||||
      console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       You can omit the mutable - parameter. In that case the default will be used.
 | 
			
		||||
       Initially the default is 'mutable'. You can set it like this:
 | 
			
		||||
       */
 | 
			
		||||
      yatta.setMutableDefault('mutable');
 | 
			
		||||
      // or
 | 
			
		||||
      yatta.setMutableDefault('immutable');
 | 
			
		||||
 | 
			
		||||
      yatta.val('new_string', "string");
 | 
			
		||||
      console.log(yatta.val('new_string') === "string"); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       yatta is chainable:
 | 
			
		||||
       */
 | 
			
		||||
      yatta.val('a', 4).val('b',5);
 | 
			
		||||
      console.log(yatta.val('a') === 4); // true
 | 
			
		||||
      console.log(yatta.val('b') === 5); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       You can alse set objects.
 | 
			
		||||
       */
 | 
			
		||||
      yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
 | 
			
		||||
      console.log(yatta.val('object').val('c').val('d') === 5); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Lists are always immutable.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.val('list', [1,2,3]);
 | 
			
		||||
      console.log(yatta.val('list')[2] === 3); // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       But there is a much more convenient way!
 | 
			
		||||
      */
 | 
			
		||||
      console.log(yatta.value.list[2] === 3) // true
 | 
			
		||||
      yatta.value.list = [3,4,5]
 | 
			
		||||
      console.log(yatta.val('list')[2] === 5) // true
 | 
			
		||||
      yatta.value.object = {c : 4}
 | 
			
		||||
      console.log(yatta.value.object.c === 4) // true
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       The downside is that you are only allowed to overwrite existing properties.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value.newProperty = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       So, how do we create new properties?
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : "Awesome"}
 | 
			
		||||
      console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       This is stupid! I don't want to overwrite all my existing properties!
 | 
			
		||||
       Very well.. The solution is that we merge yatta.value with the new assignment.
 | 
			
		||||
       For example: assuming we want to overwrite yatta.value with some object o.
 | 
			
		||||
       Then these two rules apply:
 | 
			
		||||
       * The result has all properties of o
 | 
			
		||||
       * The result has all properties of yatta.value if they don't occur under the same property-name in o
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : {Awesome : true }}
 | 
			
		||||
      console.log(yatta.value.list[2] === 5) // true, old value list still exists.
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Consider this case.
 | 
			
		||||
      */
 | 
			
		||||
      yatta.value = {newProperty : { x : 4} }
 | 
			
		||||
      console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Did you notice that you always set immutable objects if you set properties like this?
 | 
			
		||||
       Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
 | 
			
		||||
 | 
			
		||||
       One last thing. You are only allowed to set properties like this `yatta.value = o`.
 | 
			
		||||
       Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
 | 
			
		||||
      */
 | 
			
		||||
      w = yatta.value.newProperty
 | 
			
		||||
      w = "Awesome"
 | 
			
		||||
      console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
 | 
			
		||||
      */
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
window.onload = init
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								lib/.HistoryBuffer.coffee.kate-swp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/.HistoryBuffer.coffee.kate-swp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -35,18 +35,25 @@ createIwcConnector = (callback, initial_user_id)->
 | 
			
		||||
      @iwcHandler = iwcHandler
 | 
			
		||||
 | 
			
		||||
      send_ = (o)=>
 | 
			
		||||
        @send o
 | 
			
		||||
        if Object.getOwnPropertyNames(@initialized).length isnt 0
 | 
			
		||||
          @send o
 | 
			
		||||
      @execution_listener.push send_
 | 
			
		||||
 | 
			
		||||
      @initialized = {}
 | 
			
		||||
      receiveHB = (json)=>
 | 
			
		||||
        HB = json?.extras.HB
 | 
			
		||||
        HB = json.extras.HB
 | 
			
		||||
        him = json.extras.user
 | 
			
		||||
        this.engine.applyOpsCheckDouble HB
 | 
			
		||||
        @initialized[him] = true
 | 
			
		||||
      iwcHandler["Yatta_push_HB_element"] = [receiveHB]
 | 
			
		||||
 | 
			
		||||
      @sendIwcIntent "Yatta_get_HB_element", {}
 | 
			
		||||
 | 
			
		||||
      receive_ = (intent)=>
 | 
			
		||||
        o = intent.extras
 | 
			
		||||
        @receive o
 | 
			
		||||
        if @initialized[o.uid.creator]? # initialize first
 | 
			
		||||
          @receive o
 | 
			
		||||
 | 
			
		||||
      @iwcHandler["Yatta_new_operation"] = [receive_]
 | 
			
		||||
 | 
			
		||||
      if received_HB?
 | 
			
		||||
@ -55,6 +62,7 @@ createIwcConnector = (callback, initial_user_id)->
 | 
			
		||||
      sendHistoryBuffer = ()=>
 | 
			
		||||
        json =
 | 
			
		||||
          HB : @yatta.getHistoryBuffer()._encode()
 | 
			
		||||
          user : @yatta.getUserId()
 | 
			
		||||
        @sendIwcIntent "Yatta_push_HB_element", json
 | 
			
		||||
      @iwcHandler["Yatta_get_HB_element"] = [sendHistoryBuffer]
 | 
			
		||||
 | 
			
		||||
@ -90,19 +98,9 @@ createIwcConnector = (callback, initial_user_id)->
 | 
			
		||||
 | 
			
		||||
      @duiClient.sendIntent(intent)
 | 
			
		||||
 | 
			
		||||
  get_HB_intent =
 | 
			
		||||
    action: "Yatta_get_HB_element"
 | 
			
		||||
    component: ""
 | 
			
		||||
    data: ""
 | 
			
		||||
    dataType: ""
 | 
			
		||||
    flags: ["PUBLISH_GLOBAL"]
 | 
			
		||||
    extras: {}
 | 
			
		||||
 | 
			
		||||
  send_get_HB_intent = ()->
 | 
			
		||||
    duiClient.sendIntent(get_HB_intent)
 | 
			
		||||
 | 
			
		||||
  init = ()->
 | 
			
		||||
    setTimeout send_get_HB_intent, 1000
 | 
			
		||||
    proposed_user_id = null
 | 
			
		||||
    if initial_user_id?
 | 
			
		||||
      proposed_user_id = initial_user_id
 | 
			
		||||
@ -111,7 +109,7 @@ createIwcConnector = (callback, initial_user_id)->
 | 
			
		||||
      proposed_user_id = Math.floor(Math.random()*1000000)
 | 
			
		||||
    callback IwcConnector, proposed_user_id
 | 
			
		||||
 | 
			
		||||
  setTimeout init, (1000)
 | 
			
		||||
  setTimeout init, 5000
 | 
			
		||||
 | 
			
		||||
  undefined
 | 
			
		||||
module.exports = createIwcConnector
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user