rodydavis / signals.dart

Reactive programming made simple for Dart and Flutter
http://dartsignals.dev
Apache License 2.0
378 stars 44 forks source link

Documentation for connect() #248

Open wstrange opened 2 months ago

wstrange commented 2 months ago

Not grokking how connect() works or why I would want to use it.

Some docs would be great!

rodydavis commented 2 months ago

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.

wstrange commented 2 months ago

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.

rodydavis commented 2 months ago

You mean outside of using an effect?

wstrange commented 2 months ago

You mean outside of using an effect?

I'm honestly not sure I know the right question to ask.

If I have a Stream<Foo> I know I can create a stream signal from that. In my widget I'm going to get objects of AsyncState<Foo> - which is fine, I understand how to handle those (somewhat verbose, but it works).

Your previous comment implied I can 'connect' the stream to a non async signal, so my widget only deals with type Foo? And presumably only gets updated when the stream emits a new Foo into the "connected" signal?

A more complex example, ideally with a Flutter widget would really help.