Effects immediately firing instead of after store.receive call in test #1244
-
I have an appDelegateReducer that looks like this (might be familiar for isoword developers ;) ):
Simple, right? So I'm wondering why when I run a test to make sure that the setUserInterfaceStyle function is called, it seems to be executed right when store.send is called and not after store.receive is called:
Perhaps I'm misunderstanding something about how effects are run? Or maybe the compiler is over-optimizing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Whoops! For anyone who encounters the same problem, it turns out it's because I was not setting the 'setUserInterfaceStyle' closure correctly in my test:
I also noticed that they do this test in SettingsFeature (which is how I found the answer). I suppose by adding it as a simple closure, it may have the same kind of behavior as Combine's Future objects, where it just fires immediately. Adding the functionality within the .fireAndForget could be equivalent to enclosing a Future object within a Defer closure. Since I had watched so many PointFree videos, my memory is now a blur and I can't vividly recall what the explanation was, but I think I remember Brandon saying if you aren't careful with how you set your enclosures, they may be called much sooner than you 'd expect. |
Beta Was this translation helpful? Give feedback.
Whoops! For anyone who encounters the same problem, it turns out it's because I was not setting the 'setUserInterfaceStyle' closure correctly in my test:
I also noticed that they do this test in SettingsFeature (which is how I found the answer). I suppose by adding it as a simple closure, it may have the same kind of behavior as Combine's Future objects, where it just fi…