-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathknockout.sync.min.js
1 lines (1 loc) · 942 Bytes
/
knockout.sync.min.js
1
!function(e){"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?e(require("knockout"),require("funcsync"),require("socket.io"),exports):"function"==typeof define&&define.amd?define(["knockout","funcsync","socket.io","exports"],e):e(ko,funcsync,io,ko.mapping={})}(function(e,t,n,o){function i(n,o){u=n.timestamp||Date.now();var i=n.statics,c=n.dataModel,s=n.validation,f=n.methods,r=t.functify(c,o),m=t.functify(f,o);a=r,e.mapObject(o,r,s,m,i),d(o),p&&(e.applyBindings(d),p=!1)}var a,c,s,u,d=e.observable(),f={},p=!0;o.keepInSync=e.keepInSync=function(t){s=t,c=n.connect(s.URI),s.VM&&i(s.VM,f),c.on(s.modelMessage||"updateModel",function(e){s.versioned&&e.timestamp&&e.timestamp<=u||i(e,f)}),c.on(s.dataMessage||"updateData",function(t){s.versioned&&t.timestamp&&t.timestamp<=u||e.updateViewModel(d(),t.data)})},o.doSync=e.doSync=function(){c&&a&&c.emit(s.shareMessage||"share",{data:e.toJSONByPrototype(d(),a)})}});