rodydavis / signals.dart

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

Idle state on AsyncState #135

Closed Solido closed 7 months ago

Solido commented 7 months ago

I use AsyncSignal to display some computation and manage the status as exposed for users. Being not only internal I would make a common use of an idle state. Feedback?

rodydavis commented 7 months ago

Is idle before the execution is called? Or would it be a separate Boolean on the AsyncState object?

rodydavis commented 7 months ago

Or would it be a new state?

Solido commented 7 months ago

To clarify it is a state used in conjonction with UI. AsyncState by default is for any activity, not UI.

When used for UI you have a default state to return after loading/error/data

I'm interested to see how preact and others model this case but I've a direct need for it.

rodydavis commented 7 months ago

Could you provide some puedo code?

r0hit-gupta commented 7 months ago

Yeah, I feel this feature would be really handy. For reference: https://github.com/jinyus/dart_beacon?tab=readme-ov-file#asyncvalue

jinyus commented 7 months ago

@r0hit-gupta I was actually thinking of removing the idle state because it's cumbersome when you don't need it...but I found that it makes a couple scenarios more ergonomic. eg: When you're on a search page and haven't search for anything thing yet.

r0hit-gupta commented 7 months ago

@jinyus would it be possible to pass in a custom parameter? Maybe something like {initManually: true} while declaring the future signal.

jinyus commented 7 months ago

@r0hit-gupta Yes, it's called manualStart https://github.com/jinyus/dart_beacon?tab=readme-ov-file#beaconfuture

Here's an example: https://github.com/jinyus/dart_beacon/tree/main/examples/flutter_main/lib/search

Solido commented 7 months ago

This ticket is still open and we've no clear ground on it. My 2 certitudes are

Can we move this to a discussion and challenge the best implementations to solve the UI fields case?

rodydavis commented 7 months ago

Works for me! If you also want to make a PR happy to review too