Comparing version 0.2.2-alpha to 0.3.0-alpha
{ | ||
"name": "imvvm", | ||
"version": "0.2.2-alpha", | ||
"version": "0.3.0-alpha", | ||
"homepage": "https://github.com/entrendipity/imvvm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -18,3 +18,4 @@ !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.IMVVM=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
var thisAppState = {}, | ||
var ApplicationDataContext, | ||
thisAppState = {}, | ||
dataContexts = {}, | ||
@@ -160,4 +161,3 @@ watchedProps, | ||
var ApplicationDataContext = domainModel.call(this, appStateChangedHandler.bind(this, appNamespace)); | ||
ApplicationDataContext = domainModel.call(this, appStateChangedHandler.bind(this, appNamespace)); | ||
for(var dataContext in domain){ | ||
@@ -180,3 +180,3 @@ if(domain.hasOwnProperty(dataContext)){ | ||
} | ||
return new ApplicationDataContext().init(initArgs); | ||
return new ApplicationDataContext().init(initArgs); | ||
}; | ||
@@ -276,3 +276,3 @@ },{"./utils":8}],3:[function(_dereq_,module,exports){ | ||
previousState = previousState || {}; | ||
if(!('DataContext' in desc.proto)){ | ||
@@ -333,2 +333,3 @@ desc.proto.DataContext = function(initState, callback){ | ||
var desc = getDescriptor.call(this); | ||
var dataContext = function(nextState, prevState, withContext) { | ||
@@ -470,3 +471,3 @@ var model = Object.create(desc.proto, desc.descriptor); | ||
stateChangedHandler: function(dataContext, caller, callback){ | ||
this.setState({appContext: dataContext}, function(){ | ||
this.setState({applicationDataContext: dataContext}, function(){ | ||
//send all state back to caller | ||
@@ -479,9 +480,9 @@ //useful if you need to know what other parts of the app | ||
if(typeof callback === 'function'){ | ||
if(this.state === null || !('appContext' in this.state)){ | ||
if(this.state === null || !('applicationDataContext' in this.state)){ | ||
callback(void(0)); | ||
} else { | ||
if(caller in this.state.appContext){ | ||
callback(this.state.appContext[caller]); | ||
if(caller in this.state.applicationDataContext){ | ||
callback(this.state.applicationDataContext[caller]); | ||
} else if(caller === NAMESPACE) { | ||
callback(this.state.appContext); | ||
callback(this.state.applicationDataContext); | ||
} else { | ||
@@ -498,3 +499,3 @@ callback(void(0)); | ||
this.props.domain, this.stateChangedHandler, this.props.disableUndo); | ||
return {appContext: appDataContext}; | ||
return {applicationDataContext: appDataContext}; | ||
} | ||
@@ -501,0 +502,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(b){if("object"==typeof exports){module.exports=b()}else{if("function"==typeof define&&define.amd){define(b)}else{var a;"undefined"!=typeof window?a=window:"undefined"!=typeof global?a=global:"undefined"!=typeof self&&(a=self),a.IMVVM=b()}}}(function(){var d,b,a;return(function c(f,k,h){function g(n,l){if(!k[n]){if(!f[n]){var i=typeof require=="function"&&require;if(!l&&i){return i(n,!0)}if(e){return e(n,!0)}throw new Error("Cannot find module '"+n+"'")}var m=k[n]={exports:{}};f[n][0].call(m.exports,function(o){var p=f[n][1][o];return g(p?p:o)},m,m.exports,c,f,k,h)}return k[n].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(h,g,f){var e=h("./src/imvvm.js");g.exports=e},{"./src/imvvm.js":3}],2:[function(h,g,f){var e=h("./utils");var i=e.extend;f.getInitialState=function(l,q,j,r,u,y){if(typeof u!=="function"){throw new TypeError()}var w={},k={},v,o={};y===void (0)?false:y;var p=function(B,F,D){var G=false,E,A;F=F||{};if(B===void (0)){A=true;B={}}var C=function(I){var K={},J,H;if("dependsOn" in I){I.dependsOn.forEach(function(L){H={};J=L.property.split(".");J.forEach(function(N,M){if(M===0){H=B[N]}else{H=H?H[N]:void (0)}});if("alias" in L){K[L.alias]=H}else{K[J.join("$")]=H}})}return K};for(var z in r){if(r.hasOwnProperty(z)){E=C(r[z]);if(A){B[z]=new k[z](B[z],E,F[z]).init(r[z].initArgs)}else{B[z]=new k[z](B[z],E,F[z])}if(D){if(G&&D.subscribers.indexOf(z)!==-1){E=C(r[D.name]);B[D.name]=new k[D.name](B[D.name],E,F[D.name])}G=G?G:z===D.name}}}return B};var n=function(z,A,I,E){var H={},L={},G={},K=void (0),F,D,J;E===void (0)?false:E;if(!E&&(A===void (0)||A===null||Object.keys(A).length===0)){return}var C=!!A?Object.getPrototypeOf(A).constructor.classType==="DomainModel":false;if(C){L=i(A);G=A.previousState}else{if(z in o){F=Object.keys(A);D=F.length;J={};for(var B=0;B<D;B++){if(o[z][F[B]]){J[o[z][F[B]]]=true}}K={};K.name=z;K.subscribers=Object.keys(J);K=!!K.subscribers.length?K:void (0)}if(z!==l){L[z]=A;L=i(w.state,L)}else{if(E){L=i(p(),A)}else{L=i(w.state,A)}}G=w.state;L=p(L,w.state,K)}G=G||{};Object.freeze(G);w=new x(L,G,y,E);H=w.state;if(!E&&!y){H.previousState=w.previousState}Object.freeze(H);u(H,z,I);return H};var x=q.call(this,n.bind(this,l));for(var m in r){if(r.hasOwnProperty(m)){k[m]=r[m].viewModel.call(this,n.bind(this,m));if("dependsOn" in r[m]){for(var s=0,t=r[m].dependsOn.length;s<t;s++){v=r[m].dependsOn[s].property.split(".");if(v.length>1){o[v[0]]=o[v[0]]||{};o[v[0]][v[1]]=o[v[0]][v[1]]||[];if(o[v[0]][v[1]].indexOf(m)===-1){o[v[0]][v[1]].push(m)}}}}}}return new x().init(j)}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainModel");var r=f("./mixin");var q=f("./utils");var n=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var o=function(){};m(l,k.Mixin);m(h,p.Mixin);m(o,i.Mixin);var e={createClass:function(u,v,t){var y=function(){};y.prototype=new u();y.prototype.constructor=y;var x=y;var w=function(z){var A=new x();return A.construct.apply(w,arguments)};w.componentConstructor=y;y.ConvenienceConstructor=w;w.originalSpec=t;w.type=y;y.prototype.type=y;w.classType=v;y.prototype.classType=v;return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainModel:e.createClass.bind(this,o,"DomainModel"),mixin:r};g.exports=s},{"./imvvmDomainModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(j,h,f){var e=j("./utils");var k=e.extend;var g=e.getDescriptor;var i={Mixin:{construct:function(m){var n=g.call(this);n.proto.setState=m;var l=function(s,q,p,o){s=s||{};q=q||{};if(!("DataContext" in n.proto)){n.proto.DataContext=function(t,u){return n.proto.setState(t,u,true)}}if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var r=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){s=k(s,n.originalSpec.getInitialState.call(r,s,q))}if(!o&&!p){Object.defineProperty(r,"previousState",{configurable:false,enumerable:false,writable:false,value:q})}s.__proto__=r.__proto__;Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:s});return r};return l}}};h.exports=i},{"./utils":8}],5:[function(i,h,f){var e=i("./utils");var k=e.extend;var g=e.getDescriptor;var j={Mixin:{construct:function(m){var n=g.call(this);var l=function(r,s,o){var q=Object.create(n.proto,n.descriptor);var t=arguments.length;var p=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(t===0){r={};s={};o=true}else{if(t===1){if(p){o=r;r={};s={}}else{s=r;o=true}}else{if(t===2){if(p){o=s;s=r}else{o=true}}}}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState.call(q,r,s))}if(o){Object.defineProperty(q,"context",{configurable:true,enumerable:true,set:function(u){this.setState=function(v,w){return m.bind(u).call(u,k(this.state,v),this.state,w)}.bind(this);delete this.context}})}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:r});if(!o){Object.freeze(q)}return q};return l}}};h.exports=j},{"./utils":8}],6:[function(j,i,g){var f=j("./utils");var k=f.extend;var h=f.getDescriptor;var e={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(p,q,r){r=r||{};p=k(p,q);n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){p=k(p,n.originalSpec.getInitialState.call(o,p,r))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:p});Object.keys(o).forEach(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}if(Object.prototype.toString.call(this[s])==="[object Array]"){Object.freeze(this[s])}}.bind(o));p.__proto__=o.__proto__;return Object.freeze(p)};return l}}};i.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k,l,m){this.setState({appContext:k},function(){if(typeof m==="function"){if(this.state===null||!("appContext" in this.state)){m(void (0))}else{if(l in this.state.appContext){m(this.state.appContext[l])}else{if(l===e){m(this.state.appContext)}else{m(void (0))}}}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.props.initArgs,this.props.domain,this.stateChangedHandler,this.props.disableUndo);return{appContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var k={};var j=this.prototype;for(var i in this.originalSpec){if(this.originalSpec.hasOwnProperty(i)){if("get" in this.originalSpec[i]||"set" in this.originalSpec[i]){if(!("enumerable" in this.originalSpec[i])){this.originalSpec[i].enumerable=true}k[i]=this.originalSpec[i]}else{j[i]=this.originalSpec[i]}}}if(!("extend" in j)){j.extend=e.extend}return{descriptor:k,proto:j,originalSpec:this.originalSpec||{}}},extend:function(){var j={};for(var l=0;l<arguments.length;l++){var m=arguments[l];for(var k in m){if(m.hasOwnProperty(k)){j[k]=m[k]}}}return j},mixInto:function(j,k){var i;for(i in k){if(!k.hasOwnProperty(i)){continue}j.prototype[i]=k[i]}}};g.exports=e},{}]},{},[1])(1)}); | ||
!function(b){if("object"==typeof exports){module.exports=b()}else{if("function"==typeof define&&define.amd){define(b)}else{var a;"undefined"!=typeof window?a=window:"undefined"!=typeof global?a=global:"undefined"!=typeof self&&(a=self),a.IMVVM=b()}}}(function(){var d,b,a;return(function c(f,k,h){function g(n,l){if(!k[n]){if(!f[n]){var i=typeof require=="function"&&require;if(!l&&i){return i(n,!0)}if(e){return e(n,!0)}throw new Error("Cannot find module '"+n+"'")}var m=k[n]={exports:{}};f[n][0].call(m.exports,function(o){var p=f[n][1][o];return g(p?p:o)},m,m.exports,c,f,k,h)}return k[n].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(h,g,f){var e=h("./src/imvvm.js");g.exports=e},{"./src/imvvm.js":3}],2:[function(h,g,f){var e=h("./utils");var i=e.extend;f.getInitialState=function(l,q,k,r,u,y){if(typeof u!=="function"){throw new TypeError()}var x,w={},j={},v,o={};y===void (0)?false:y;var p=function(B,F,D){var G=false,E,A;F=F||{};if(B===void (0)){A=true;B={}}var C=function(I){var K={},J,H;if("dependsOn" in I){I.dependsOn.forEach(function(L){H={};J=L.property.split(".");J.forEach(function(N,M){if(M===0){H=B[N]}else{H=H?H[N]:void (0)}});if("alias" in L){K[L.alias]=H}else{K[J.join("$")]=H}})}return K};for(var z in r){if(r.hasOwnProperty(z)){E=C(r[z]);if(A){B[z]=new j[z](B[z],E,F[z]).init(r[z].initArgs)}else{B[z]=new j[z](B[z],E,F[z])}if(D){if(G&&D.subscribers.indexOf(z)!==-1){E=C(r[D.name]);B[D.name]=new j[D.name](B[D.name],E,F[D.name])}G=G?G:z===D.name}}}return B};var n=function(z,A,I,E){var H={},L={},G={},K=void (0),F,D,J;E===void (0)?false:E;if(!E&&(A===void (0)||A===null||Object.keys(A).length===0)){return}var C=!!A?Object.getPrototypeOf(A).constructor.classType==="DomainModel":false;if(C){L=i(A);G=A.previousState}else{if(z in o){F=Object.keys(A);D=F.length;J={};for(var B=0;B<D;B++){if(o[z][F[B]]){J[o[z][F[B]]]=true}}K={};K.name=z;K.subscribers=Object.keys(J);K=!!K.subscribers.length?K:void (0)}if(z!==l){L[z]=A;L=i(w.state,L)}else{if(E){L=i(p(),A)}else{L=i(w.state,A)}}G=w.state;L=p(L,w.state,K)}G=G||{};Object.freeze(G);w=new x(L,G,y,E);H=w.state;if(!E&&!y){H.previousState=w.previousState}Object.freeze(H);u(H,z,I);return H};x=q.call(this,n.bind(this,l));for(var m in r){if(r.hasOwnProperty(m)){j[m]=r[m].viewModel.call(this,n.bind(this,m));if("dependsOn" in r[m]){for(var s=0,t=r[m].dependsOn.length;s<t;s++){v=r[m].dependsOn[s].property.split(".");if(v.length>1){o[v[0]]=o[v[0]]||{};o[v[0]][v[1]]=o[v[0]][v[1]]||[];if(o[v[0]][v[1]].indexOf(m)===-1){o[v[0]][v[1]].push(m)}}}}}}return new x().init(k)}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainModel");var r=f("./mixin");var q=f("./utils");var n=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var o=function(){};m(l,k.Mixin);m(h,p.Mixin);m(o,i.Mixin);var e={createClass:function(u,v,t){var y=function(){};y.prototype=new u();y.prototype.constructor=y;var x=y;var w=function(z){var A=new x();return A.construct.apply(w,arguments)};w.componentConstructor=y;y.ConvenienceConstructor=w;w.originalSpec=t;w.type=y;y.prototype.type=y;w.classType=v;y.prototype.classType=v;return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainModel:e.createClass.bind(this,o,"DomainModel"),mixin:r};g.exports=s},{"./imvvmDomainModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(j,h,f){var e=j("./utils");var k=e.extend;var g=e.getDescriptor;var i={Mixin:{construct:function(m){var n=g.call(this);n.proto.setState=m;var l=function(s,q,p,o){s=s||{};q=q||{};if(!("DataContext" in n.proto)){n.proto.DataContext=function(t,u){return n.proto.setState(t,u,true)}}if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var r=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){s=k(s,n.originalSpec.getInitialState.call(r,s,q))}if(!o&&!p){Object.defineProperty(r,"previousState",{configurable:false,enumerable:false,writable:false,value:q})}s.__proto__=r.__proto__;Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:s});return r};return l}}};h.exports=i},{"./utils":8}],5:[function(i,h,f){var e=i("./utils");var k=e.extend;var g=e.getDescriptor;var j={Mixin:{construct:function(m){var n=g.call(this);var l=function(r,s,o){var q=Object.create(n.proto,n.descriptor);var t=arguments.length;var p=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(t===0){r={};s={};o=true}else{if(t===1){if(p){o=r;r={};s={}}else{s=r;o=true}}else{if(t===2){if(p){o=s;s=r}else{o=true}}}}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState.call(q,r,s))}if(o){Object.defineProperty(q,"context",{configurable:true,enumerable:true,set:function(u){this.setState=function(v,w){return m.bind(u).call(u,k(this.state,v),this.state,w)}.bind(this);delete this.context}})}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:r});if(!o){Object.freeze(q)}return q};return l}}};h.exports=j},{"./utils":8}],6:[function(j,i,g){var f=j("./utils");var k=f.extend;var h=f.getDescriptor;var e={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(p,q,r){r=r||{};p=k(p,q);n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){p=k(p,n.originalSpec.getInitialState.call(o,p,r))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:p});Object.keys(o).forEach(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}if(Object.prototype.toString.call(this[s])==="[object Array]"){Object.freeze(this[s])}}.bind(o));p.__proto__=o.__proto__;return Object.freeze(p)};return l}}};i.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k,l,m){this.setState({applicationDataContext:k},function(){if(typeof m==="function"){if(this.state===null||!("applicationDataContext" in this.state)){m(void (0))}else{if(l in this.state.applicationDataContext){m(this.state.applicationDataContext[l])}else{if(l===e){m(this.state.applicationDataContext)}else{m(void (0))}}}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.props.initArgs,this.props.domain,this.stateChangedHandler,this.props.disableUndo);return{applicationDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var k={};var j=this.prototype;for(var i in this.originalSpec){if(this.originalSpec.hasOwnProperty(i)){if("get" in this.originalSpec[i]||"set" in this.originalSpec[i]){if(!("enumerable" in this.originalSpec[i])){this.originalSpec[i].enumerable=true}k[i]=this.originalSpec[i]}else{j[i]=this.originalSpec[i]}}}if(!("extend" in j)){j.extend=e.extend}return{descriptor:k,proto:j,originalSpec:this.originalSpec||{}}},extend:function(){var j={};for(var l=0;l<arguments.length;l++){var m=arguments[l];for(var k in m){if(m.hasOwnProperty(k)){j[k]=m[k]}}}return j},mixInto:function(j,k){var i;for(i in k){if(!k.hasOwnProperty(i)){continue}j.prototype[i]=k[i]}}};g.exports=e},{}]},{},[1])(1)}); |
@@ -6,2 +6,8 @@ /* global AppViewModel, PersonsViewModel, HobbiesViewModel */ | ||
var domainObjects = { | ||
'hobbies': { | ||
viewModel: HobbiesViewModel, | ||
initArgs : [], | ||
dependsOn: [{property: 'persons.selected'}, | ||
{property: 'busy', alias: 'appIsBusy'}] | ||
}, | ||
'persons': { | ||
@@ -13,11 +19,2 @@ viewModel: PersonsViewModel, | ||
}, | ||
'hobbies': { | ||
viewModel: HobbiesViewModel, | ||
initArgs : [], | ||
dependsOn: [{property: 'persons.selected'}, | ||
{property: 'myAppState.appState', alias: 'appState'}] | ||
}, | ||
'myAppState': { | ||
viewModel: AppViewModel | ||
} | ||
}; |
@@ -11,2 +11,3 @@ | ||
online: typeof nextState.online === 'boolean' ? nextState.online : false, | ||
busy: nextState.busy === void(0) ? false : nextState.busy | ||
} | ||
@@ -25,13 +26,5 @@ }, | ||
appName: { | ||
get: function(){ | ||
return this.state.appName; | ||
}, | ||
}, | ||
online: { | ||
get: function(){ | ||
return this.state.online; | ||
} | ||
}, | ||
setBusyTo: function(val){ | ||
this.setState({busy: val}); | ||
} | ||
}); |
@@ -33,7 +33,3 @@ /*jshint camelcase:false */ | ||
}, | ||
appState: { | ||
get: function(){ | ||
this.state.appState; | ||
} | ||
}, | ||
getInitialState: function(nextState, prevState){ | ||
@@ -40,0 +36,0 @@ return { |
@@ -17,14 +17,14 @@ /** | ||
console.log('------------------------------------------ Current Application State ------------------------------------------') | ||
console.log(this.state.appContext); | ||
console.log(this.state.applicationDataContext); | ||
return ( | ||
<div> | ||
<NavBarView appContext={this.state.appContext} /> | ||
<NavBarView appContext={this.state.applicationDataContext} /> | ||
<div className="container"> | ||
<div className="row"> | ||
<div className="col-md-4"> | ||
<SideBarView appContext={this.state.appContext} /> | ||
<SideBarView appContext={this.state.applicationDataContext} /> | ||
</div> | ||
<div className="col-md-8"> | ||
<DetailsView appContext={this.state.appContext} /> | ||
<DetailsView appContext={this.state.applicationDataContext} /> | ||
</div> | ||
@@ -31,0 +31,0 @@ </div> |
@@ -25,2 +25,3 @@ /** | ||
var current = this.props.appContext.hobbies.selected; | ||
var display; | ||
@@ -52,2 +53,8 @@ var list = collection.map(function(hobby){ | ||
display = this.props.appContext.hobbies.appIsBusy ? "Im Busy! Go away..." : ( | ||
<div className="list-group"> | ||
{list} | ||
</div> | ||
); | ||
return ( | ||
@@ -57,5 +64,3 @@ <div> | ||
funcAdd={this.addHobby} /> | ||
<div className="list-group"> | ||
{list} | ||
</div> | ||
{display} | ||
</div> | ||
@@ -62,0 +67,0 @@ ); |
@@ -17,5 +17,13 @@ /** | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.props.appContext.undo(); | ||
}, | ||
toggleBusyState: function(e){ | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.props.appContext.setBusyTo(!this.props.appContext.busy); | ||
}, | ||
render: function(){ | ||
var busyBtnTxt = this.props.appContext.busy ? "Stop Now" : "Get Busy"; | ||
return ( | ||
@@ -40,5 +48,7 @@ <nav className="navbar navbar-default" role="navigation"> | ||
<button onClick={this.undo} className="btn btn-default"> | ||
<span className="glyphicon glyphicon-repeat"> | ||
</span> | ||
Undo | ||
</button> | ||
<button onClick={this.toggleBusyState} className="btn btn-default"> | ||
{busyBtnTxt} | ||
</button> | ||
</form> | ||
@@ -45,0 +55,0 @@ </div> |
@@ -7,4 +7,4 @@ 'use strict'; | ||
{id:'2', firstName:'Lisa', lastName: "Jones", gender:'female', dob:'1985-02-22', occupation:'accountant', hobbies: ['reading']}, | ||
{ lastName: "ID", gender:'female', dob:'1975-12-11', occupation:'unemployed', hobbies: ['watching TV']}]; | ||
{ firstName: "John", lastName: "Citizen", gender:'male', dob:'1975-12-11', occupation:'unemployed', hobbies: ['watching TV']}]; | ||
} | ||
}; |
{ | ||
"name": "imvvm", | ||
"description": "Immutable MVVM for React", | ||
"version": "0.2.2-alpha", | ||
"version": "0.3.0-alpha", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "imvvm", |
@@ -11,3 +11,4 @@ | ||
var thisAppState = {}, | ||
var ApplicationDataContext, | ||
thisAppState = {}, | ||
dataContexts = {}, | ||
@@ -153,4 +154,3 @@ watchedProps, | ||
var ApplicationDataContext = domainModel.call(this, appStateChangedHandler.bind(this, appNamespace)); | ||
ApplicationDataContext = domainModel.call(this, appStateChangedHandler.bind(this, appNamespace)); | ||
for(var dataContext in domain){ | ||
@@ -173,3 +173,3 @@ if(domain.hasOwnProperty(dataContext)){ | ||
} | ||
return new ApplicationDataContext().init(initArgs); | ||
return new ApplicationDataContext().init(initArgs); | ||
}; |
@@ -15,3 +15,3 @@ | ||
previousState = previousState || {}; | ||
if(!('DataContext' in desc.proto)){ | ||
@@ -18,0 +18,0 @@ desc.proto.DataContext = function(initState, callback){ |
@@ -10,2 +10,3 @@ | ||
var desc = getDescriptor.call(this); | ||
var dataContext = function(nextState, prevState, withContext) { | ||
@@ -12,0 +13,0 @@ var model = Object.create(desc.proto, desc.descriptor); |
@@ -7,3 +7,3 @@ | ||
stateChangedHandler: function(dataContext, caller, callback){ | ||
this.setState({appContext: dataContext}, function(){ | ||
this.setState({applicationDataContext: dataContext}, function(){ | ||
//send all state back to caller | ||
@@ -16,9 +16,9 @@ //useful if you need to know what other parts of the app | ||
if(typeof callback === 'function'){ | ||
if(this.state === null || !('appContext' in this.state)){ | ||
if(this.state === null || !('applicationDataContext' in this.state)){ | ||
callback(void(0)); | ||
} else { | ||
if(caller in this.state.appContext){ | ||
callback(this.state.appContext[caller]); | ||
if(caller in this.state.applicationDataContext){ | ||
callback(this.state.applicationDataContext[caller]); | ||
} else if(caller === NAMESPACE) { | ||
callback(this.state.appContext); | ||
callback(this.state.applicationDataContext); | ||
} else { | ||
@@ -35,3 +35,3 @@ callback(void(0)); | ||
this.props.domain, this.stateChangedHandler, this.props.disableUndo); | ||
return {appContext: appDataContext}; | ||
return {applicationDataContext: appDataContext}; | ||
} | ||
@@ -38,0 +38,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121071
49
2037