We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
对于一些异步操作,往往需要定义一些临时变量在模板中,来表示异步操作当前的状态
类似这样
{#if pending} loading {#elseif failed} { error } {#else} { response } {/if}
Regular.extend( { // ... async request() { this.data.pending = true this.data.failed = false this.$update() try { this.data.response = await request( ... ) } catch ( e ) { this.data.failed = true this.data.error = e.message } this.data.pending = false this.$update() } } )
当存在多个异步操作的情况下会更加麻烦,this.data上要新增很多临时变量,还要避免变量间的命名冲突,很容易产生bug
有了 await 命令之后:
{#await promise} loading {#then response} { response } {#catch e} { e.message } {/await}
模板就可以拥有这种能力
btw:如果regular能把自定义{#command}的能力开放给开发者的话,会是一个很大的亮点
The text was updated successfully, but these errors were encountered:
这个idea真的很好。。。 但是因为和具体解析相关,会导致Parser 和 Render 部分 更难解耦吧?
之前考虑过一些重构思路,第一条可能就是Parser和Render部分分包维护(但可能是monorepo的形式)
Sorry, something went wrong.
支持重构,可以先找时间加上 eslint,现在写代码有点纠结,jshint 好像没有很强的代码规范约束... 还有目录结构,变量命名,注释也可以加起来
还有一个问题...
和 {#await} 配套的有 {#then} 和 {#catch},这就相当于注册一个 await 要同时占用 then 和 catch 两个关键字
{#await}
{#then}
{#catch}
假如开发者或者我们自己定义了另一个 catch 用于别的用途,而且是独立使用的,混用的话会有问题
{#await promise} {#then response} {#catch e} <!-- 不是和 await 配套的 catch,而是开发者自己注册上去的一个 command --> {#catch e} {/await}
No branches or pull requests
对于一些异步操作,往往需要定义一些临时变量在模板中,来表示异步操作当前的状态
类似这样
当存在多个异步操作的情况下会更加麻烦,this.data上要新增很多临时变量,还要避免变量间的命名冲突,很容易产生bug
有了 await 命令之后:
模板就可以拥有这种能力
btw:如果regular能把自定义{#command}的能力开放给开发者的话,会是一个很大的亮点
The text was updated successfully, but these errors were encountered: