开发者

How To Persist The Sate of A Webflow

开发者 https://www.devze.com 2023-04-13 02:26 出处:网络
Say I have a webflow with N states. How can I persist a user\'s state to a database so that if he leaves the flow somewhere in the middle, he can start where he le开发者_开发百科ft off, next time he l

Say I have a webflow with N states. How can I persist a user's state to a database so that if he leaves the flow somewhere in the middle, he can start where he le开发者_开发百科ft off, next time he logs into the system, no matter what machine he uses when he does.


General question, you're essentially dealing with a long transaction. This is generally a really hard problem, as you have to deal with concurrency issues. However, if you wanted to do this, you'd probably have to have Domain objects that correspond to the entities involved

class ShoppingCart
{
    static belongsTo = [ person : Person ]
    static hasMany = [ item : ShoppingCartItem ]
    static hasOne = [state : ShoppingCartState ]
}

You could use the State pattern to encapsulate the state, and save it to the DB at the end of every web flow transition.

If your use case is simpler, you may be able to do something with Audit Logging.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号