开发者

UI changes triggering events vs. UI changes triggered programmatically

开发者 https://www.devze.com 2023-04-04 18:01 出处:网络
Here is a problem I often come across: I start building my app and define eve开发者_JAVA百科nt handlers for changes in the UI, e.g. a user uses a select list -> event triggered -> event handled.

Here is a problem I often come across:

I start building my app and define eve开发者_JAVA百科nt handlers for changes in the UI, e.g. a user uses a select list -> event triggered -> event handled.

At some point I want to programmatically make changes to the UI and if those changes trigger events, handlers go off without any way of controlling them.

Is there some way around this?


Consider a smarter command implementation. Instead of having the logic directly in UI event handlers, you keep them dumb, and only executing certain tasks via command functions/classes/dispatcher/.. anything you want. Then prior to making your changes to UI, you can instruct command dispatcher to not run certain task, in any way suits you.

0

精彩评论

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