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
import{AwaitC,AwaitState}from'@simpli/await-controller'// any axios GET request with the endpoint ending with 'user/principal' // will trigger this controllerAwaitC.axios('loadingPrincipal','GET:user/principal')// you can get the state of this request at any time, using the same name,// possible states: ACTIVE, INITIAL, SUCCESS, ERROR, <customs>constloadingPrincipalState: AwaitState=AwaitC.get('loadingPrincipal')// or simply check if it's activeconstisActive: boolean=AwaitC.isActive('loadingPrincipal')// you can manually change a controller state, you can put any value AwaitC.set('loadingPrincipal',AwaitState.ACTIVE)// you can create any process with a promise and associate it with a controllerconstprocess=AwaitC.process('loadingPrincipal',async()=>{})// then you can start the processconstresult=awaitprocess.start()// debounce with the state active even when not actually processing,// but just waiting in the debounceconstprocess=AwaitC.debounce('loadingPrincipal',500,{/*lodash debounce options, not mandatory*/},async()=>{})// there is a shortcut for process/startconstresult=awaitAwaitC.run('loadingPrincipal',async()=>{})
using with vue-await
oh and by the way, I think we should use directives
<divv-await.noError="loadingPrincipal" v-await.class="loading-circle"><divv-await.successv-await.class="placeholder-text">{{ principal.title }}</div></div><divv-await.error="loadingPrincipal">Error on request</div>
Directives:
v-await.active, v-await.initial, v-await.success, v-await.error, v-await.notActive, v-await.notInitial, v-await.noSuccess, v-await.noError - you can put the await controller name on it or on it's parent or grandparent, and then, it will render it's content only when the controller is on choosen state
v-await.class - the class the component will have when it's controller is ACTIVE or it's parent or grandparent is ACTIVE
We don't need vue spinner integration anymore because we can have a vue-spinner with the v-await.active directive on it.
And with this kind of configuration we can have unobstrusive loading indicators and placeholders
It should be a library usable not only by vue, but something any library could use as a comunication pattern
The text was updated successfully, but these errors were encountered: