No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
A periodic action is a ViewModel action that runs automatically over and over again when the Disabled expression is False. | A periodic action is a ViewModel action that runs automatically over and over again when the Disabled expression is False. | ||
'''<u>Warning: If you have a interval shorter then several seconds (>5000) - you have to have a | '''<u>Warning: If you have a interval shorter then several seconds (>5000) - you have to have a working Disabled expression, read more below.</u>''' | ||
===== How it works ===== | ===== How it works ===== |
Revision as of 09:53, 14 October 2023
A periodic action is a ViewModel action that runs automatically over and over again when the Disabled expression is False.
Warning: If you have a interval shorter then several seconds (>5000) - you have to have a working Disabled expression, read more below.
How it works
In the ViewModel editor:
You typically use this for:
- Refreshing a view in WPF with selfVM.Refresh if, for example, your root object is in a state that changes server side.
- Automatically navigate on a change in the database (for example, after login when a current user has been set).
- Updating a calculated value or transient collection/association that you show on the screen.
- If you want the persisted attribute A to get assigned to the derived attribute B, you can do so with a periodic action that starts whenever
self.A<>self.B
. Set the Disabled expression toself.A=self.B
(this way it does NOT run when A=B, only when A<>B). In the action expression, you then assign B to A with the expressionself.A:=self.B
. Set Interval to a number X and the disable expression will become false when B is updated; X milliseconds after B gets a new value, the action will execute, and A will now become equal to B, and then the disable expression again is true, and the action rests. - The periodic action is a good way to detect changes that are not easily connected to user action. If you have a user entering a value and you want to do something upon apply, you can also do this with a reversederived attribute.
- If you want the persisted attribute A to get assigned to the derived attribute B, you can do so with a periodic action that starts whenever
Warning: If you have a interval shorter then several seconds (>5000) - you have to have a functional Disabled expression
For every execution of a period action, the client needs to call the MDrivenServer. That means that if you have a interval setting of 100 ms, the client has to call the server every 100 ms, until the Disabled expression is True.
The effect of that is that both your client and the server might spend all their time (and CPU) frantically calling the server. AVOID THIS. Check the client browsers network tab to verify that this is not happening.
See also
MDrivenServer periodic server-side actions which is a different thing, but usually works in conjunction with ViewModel periodic actions.