You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
// App.jsximportReact,{useState,useCallback}from'react';import{set,useService}from'lamp-luwak';// Primary syntax (you can modify count only in owned class methods not in React components or another classes)classCounter{count=0;// auto getter/setter for non function valueinc=()=>this.count+=1;dec(){this.count-=1;}// That syntax is possible too}constComp=()=>{const{ count, inc, dec }=useService(Counter);// Need to be create new proxy for each component for detection of using properties in that React component and update It only if update used propertyreturn(<><i>{count}</i><buttononClick={inc}>+</button><buttononClick={dec}>-</button></>)}classCurrentUser{firstName='Jonh';// Only scalar value (or plain object) possible here, functions no possiblelastName='Doe'getname(){// getter is computed foreverreturnthis.firstName+' '+this.lastName}}// SecondaryclassCounter{state={count: 0},inc=()=>modify().count+=1;dec=()=>modify().count-=1;}classCounter{state=0,inc=()=>set(get()+1);dec=()=>set(get()-1);}// OthersclassCounter{state=0,inc=()=>this.state+=1;dec=()=>this.state-=1;}constComp=()=>{constcounter=useService(Counter);return(<><i>{counter.state}</i><buttononClick={counter.inc}>+</button><buttononClick={counter.dec}>-</button></>)}constComp=()=>{const{ state, inc, dec }=service(Counter);return(<><i>{state}</i><buttononClick={inc}>+</button><buttononClick={dec}>-</button></>)}classCounterStore{state=0,inc(){this.state+=1;}dec(){this.state-=1;}}constCounter=store(0,{inc: ()=>set(state=>state+1);
dec: ()=>set(state=>state-1);});constComp=()=>{const{}}classCounterStore{state=0,inc(){set(state=>state+1);}dec(){set(state=>state-1);}}classCounterStore{count=newFlow(0);inc(){this.count.set(this.count.get()+1);}dec(){this.count.set(this.count.get()-1);}}constCounter=()=>{constcount=flow(0);return{inc: ()=>count.set(count.get()+1),dec: ()=>count.set(count.get()-1)}}// При вызове через service, можно определять count как Flow при обращение и делать ему get(), что бы вставлять как значениеconstCounterStore=()=>({
count =0,inc: ()=>set(({count})=>{count: count+1}),// ????dec: ()=>set(state=>state-1),});constCount=()=>{const{ state }=useService(CounterStore);return<p>{state}</p>;};constButtons=()=>{const{ inc, dec }=useService(CounterStore);return(<><buttononClick={inc}>+</button><buttononClick={dec}>-</button></>);};constApp=()=>(<><Count/><Buttons/><Count/><Buttons/></>);exportdefaultApp;
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: