Why block behave like this [BREAK Block]

Hello, I am testing on the looping concepts given by Kodular and then I have used the for each loop and break just for a testing

I think It has to stop if the myAgentFound == true but it does not and shows the notifier after myAgentFound == true.

Am I right in using this block.

I want to just break out of the loop after myAgentFound == true.

Anyone who can help me to understand what’s going on.

This is meant to be used at the end of the for each item in list block. I don’t believe it will work with how you’re using it.

Show me the my mine which will work like I explain

In your blocks the break block needs to be in the GotValue event. The value of myAgentFound is not set until then.

I think you shouldn’t use Firebase calls in a loop because as it connects to internet, it will have some delay, and it will cause a lot of Got Value event fired at the once. You shouldn’t call another task before previous task finishes.

Calls to Firebase are performed asynchronously, meaning the loop will send fetch calls for all values in the list without waiting for a result. The GotTag event is called independently for each value as and when the request is resolved. The break block won’t work here because the program’s control never gets to the “then” part. The variable you’re testing is not guaranteed to be true while the loop is being run.

I suggest you edit your blocks such that the program waits till all values are fetched from Firebase

1 Like