:wave: <@U0KMMQA20> My workflow question of the d...
# squarelibraries
y
👋 @Zach Klippenstein (he/him) [MOD] My workflow question of the day: can the lifetime of a
Flow
worker go beyond a single
Action
? I want to subscribe to a
Flow
for the lifetime of a workflow, but it looks like any subsequent
action
would cancel the
Flow
immediately and you have to re-subscribe to the
flow
in the next
render
call. I remember reading that it’s possible to subscribe to external event sources, but this is not how I expect
Flow
worker to work so I’m probably doing something wrong.
r
The worker will keep running, and stay subscribed, so long as you make an identical
runningWorker
call on each
render
.
Where identical means that
doesSameWorkAs
returns true, and the optional
key
param to
runningWorker
matches.
For the kind of always-running thing you’re talking about, I’ll usually have that
runningWorker
call as the first line of my
render
, before
when(state)
or whatever.
y
Thanks Ray! it’s all working as expected now. I thought I needed to have the
runningWorker
call in one of the
when(state)
branch to avoid re-subscribing to the flow. The way it memorises existing worker is cool and it makes things look more declarative 👍
z
That was the intention, try to make things look as declarative as possible. Thanks for the feedback 🙂