Skip to content

Commit 2842fc6

Browse files
committed
Explain cached timer's automatic cancellation
Signed-off-by: Jimmy Tanagra <[email protected]>
1 parent 30d80fb commit 2842fc6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tutorials/getting_started/rules_advanced.md

+4
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ Also notice a line was added to `lightsOut` to delete the entry in the `cache` w
170170
That will cause the rule to create a new timer the next time the rule runs.
171171
It could be coded to reuse the Timer instead which is an exercise for the reader.
172172

173+
Another benefit of saving the timer in the `cache` is that it will be cancelled when the last script that references the cache is unloaded or reloaded.
174+
This will prevent the timer from executing after the original script had been removed or reloaded.
175+
Care must still be taken within the timer function not to reschedule itself if it has been cancelled.
176+
173177
Save and test that the rule sends the on and off commands as described.
174178

175179
### But only if: Conditions

0 commit comments

Comments
 (0)