Replies: 9 comments
-
Definitely want to add examples to the docs! https://dartsignals.dev/async/connect/ The biggest reason to use it over StreamSignal is you work off of type T instead of AsyncState. |
Beta Was this translation helpful? Give feedback.
-
In the example in the docs, how do you actually "advance" or consume the signal value when a new value is emitted from a stream? A more concrete example would really help. Something that consumes the connected signal. |
Beta Was this translation helpful? Give feedback.
-
You mean outside of using an effect? |
Beta Was this translation helpful? Give feedback.
-
I'm honestly not sure I know the right question to ask. If I have a Your previous comment implied I can 'connect' the stream to a non async signal, so my widget only deals with type A more complex example, ideally with a Flutter widget would really help. |
Beta Was this translation helpful? Give feedback.
-
+1, having a bit of trouble understanding connect. |
Beta Was this translation helpful? Give feedback.
-
It really depends on the data you are connecting to. I will present 2 examples for async data, user state and a database export event.
final user$ = signal<User?>(null);
final Stream<User?> onAuthChanged = ...;
...
connect<User?>(user$) << onAuthChanged; Also another common use case for connect is when working with RxDart.
final Database db;
late final dbExport = Stream.periodic(Duration(minutes: 5), () => db.backup());
...
final export$ = dbExport.toSignal(); |
Beta Was this translation helpful? Give feedback.
-
@rodydavis Thanks! The first example is my use case. |
Beta Was this translation helpful? Give feedback.
-
@rodydavis Sorry, one last question. In the following example, my
|
Beta Was this translation helpful? Give feedback.
-
You have to set up the connect and add the stream separately. I was having issues trying to define them both in the late initializers but would work if I added the stream in an init method |
Beta Was this translation helpful? Give feedback.
-
Not grokking how connect() works or why I would want to use it.
Some docs would be great!
Beta Was this translation helpful? Give feedback.
All reactions