Should `Effect.init(value:)` take an `@autoclosure`?

I think Effect.init(value:) should evaluate value lazily at the time its subscribed, which can be later-on if theres multiple effects, so it can actually produce a different result.

Afaik this can be done with @autoclosure @escaping without loosing ergonomics.

Similar with Effect.init(error:).

I can think more about this, provide code or PR if theres support. First I wanna see if Im not missing some obvious counterargument.

We discussed this before open sourcing but ultimately decided to avoid laziness for this API, since Effect.init(value:) should really only be invoked with a pure value, but we're definitely open to revisit with some discussion! Maybe an example of code that would benefit from laziness would help?

Terms of Service

Privacy Policy

Cookie Policy