I need help to understand how flows and atomics work

180 views
Skip to first unread message

Alex

unread,
Aug 1, 2023, 6:08:39 PM8/1/23
to Automate
I have about 15 flows within my flow and each one loads the same atomic values that are stored by one of the flows. What I would like to implement is to have a separate flow that would load all the atomic values and I want to pass this flow to each flow so when they start they first execute this 'atomic loading' flow. So it's kind of trying to implement OOP I guess but I just want to figure out how to avoid the repetition of same blocks in each flow. Can somebody help me to understand what is the best approach here to load the atomic values in all my flows without repeating same blocks?

Henrik "The Developer" Lindqvist

unread,
Aug 3, 2023, 4:35:07 PM8/3/23
to Automate
Atomic only work without a single flow.
Use the database blocks to share persistent data between flows.

Alex

unread,
Aug 3, 2023, 4:46:23 PM8/3/23
to Automate
In my case I am using it within the same flow that has 15+ other flows and atomics work fine but I have to repeat the same blocks in each flow  - "Load Atomic"  to load my variables(7-8 variables) if I use database  it will not solve my problem cause I will have to do absolutely the same - repeating code in each flow to load the variables. What I want is to know how I could do something like I do in OOP - call a function in all flows that would return the values (or load atomics) to the calling flow.

Henrik "The Developer" Lindqvist

unread,
Aug 3, 2023, 5:14:54 PM8/3/23
to Automate
There's currently no way to "reuse code" in between flow, it's a feature on the to-do list.

Alex

unread,
Aug 3, 2023, 5:38:10 PM8/3/23
to Automate
Thank you.

Shari Shark

unread,
Aug 3, 2023, 5:55:18 PM8/3/23
to automa...@googlegroups.com
You can put your variables into a dictionary and store it as an atomic variable. Then you only have to load a single variable at any one time.

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/80284cbd-105f-4c70-bc64-d28b0d09a1e3n%40googlegroups.com.

Shari Shark

unread,
Aug 3, 2023, 6:07:29 PM8/3/23
to automa...@googlegroups.com
Also, you can use database to load all values at one go, so no need to do multiple loads.

Alex

unread,
Aug 3, 2023, 6:10:13 PM8/3/23
to Automate
Man, that's a good idea. That should help me to avoid repetition of the blocks. Thank you :)

Alex

unread,
Aug 3, 2023, 6:12:21 PM8/3/23
to Automate
But anyway the "reuse" code between flows is needed. I have catch block for all my flows that does the same things (5-6 blocks) on failure  and if I could just put it in one function(flow) and call it returning back to the flow after executing the blocks 
that would be great.

Shari Shark

unread,
Aug 3, 2023, 6:28:40 PM8/3/23
to automa...@googlegroups.com
You need to have individual catch block on each flow. But the processing block can be one flow. Then on failure, use the sub routine block to call the processing blocks.

Sub routine block waits for the child fiber to complete before proceeding. 

Shari Shark

unread,
Aug 3, 2023, 6:32:54 PM8/3/23
to automa...@googlegroups.com
But needing to catch failures isn't exactly good coding. You should aim to cover all the cases and last resort is the catch block.

So far, I rarely need the catch block in my flows.
Message has been deleted

Alex

unread,
Aug 3, 2023, 7:39:17 PM8/3/23
to Automate
Yeah, I use catch only just in case.
 So far it's rarly needed but if something happens I want to be covered and have catch block to restart the flow after a delay.
I am not very clear what subroutine do in this scenario, it still needs to be created multiple times for each flow unless you connect all flows to a single  subroutine but in my project it would be a mess since I implemented 15+ flows so it's huge. 
Unless you mean I could create a single subroutine and call it from all flows which I really was looking for but I doubt it.

Henrik "The Developer" Lindqvist

unread,
Aug 4, 2023, 7:38:27 AM8/4/23
to Automate
False. Using Failure catch and just try to perform the thing that might fail is much more reliable that first checking every state to see if "should" be possible, then try to perform the action, and possibly fail anyway.
Don't be afraid of failure. ;)

Alex

unread,
Aug 4, 2023, 9:41:07 AM8/4/23
to Automate
Anyway I just tried creating a separate single flow of blocks that is called from each other flow after "catch" triggers and I can't find a way to pass the failblock, failtype and failMessage from 'Catch' to the newly created flow. It always passes null. Any idea why? Once again All my flows are in the same file(flow).

Henrik "The Developer" Lindqvist

unread,
Aug 6, 2023, 6:59:18 AM8/6/23
to Automate
As said, try logging the variables before the Flow start block to ensure the problem isn't elsewhere.
Reply all
Reply to author
Forward
0 new messages