Closed busslina closed 5 months ago
I use a lot these side effects but not sure whether you think they must be included in the package.
What's a use case for firstBuild
in Dart? I'd probably be open to having a use.isFirstBuild
since the exact same side effect is in ReArch for Rust. Just want to make sure it supports a sound use case.
Not sure about the other two--you probably shouldn't do callonceAsync
in most situations and now there's a use.disposable
so I'm not sure how use.onDispose
would fit
What's a use case for firstBuild in Dart?
I had it only for Flutter and I just migrated to Dart today. I didn't used on pure Dart for now, but I moved it because it does not use any Flutter exclusive feature (like controllers, ...). So I can't give you any use case, but is so "cheap" that today I got to the conclusion that it could be also in the Dart extension..
use.callonceAsync
I use it exclusively to request focus for a FocusNode
because doing it synchronously seems to not work the most of times.
use.onDispose
You're right. Now, with disposable
I did a search and seems I'm not using it. So forget it
just add a test or two please, see comment
Sure. It's late in Spain but tomorrow will be done
Actually just realized there already is a use.isFirstBuild
:
https://github.com/GregoryConrad/rearch-dart/blob/238507a3d0a76a29be9876b71fdb0c4699e8d78e/packages/rearch/lib/src/side_effects.dart#L148
I use it exclusively to request focus for a FocusNode because doing it synchronously seems to not work the most of times.
Ahh. That might be fine then, but I'd be hesitant about adding it since it might give people bad ideas on how to use it. Feel free to continue using it though for that if calling it sync doesn't work
I'm not sure how a test on ScrollController
would look like. Can you give me some tips/guidelines. Do you mean to create a scrollable test widget and test the controller on it? Testing just that it get disposed?
Do you mean to create a scrollable test widget and test the controller on it?
yea exactly, just making sure the scroll controller returned is working as expected for the given input parameters.
You asked me for a use case for use.onDispose
. I give you one:
Sometimes you need to perform some async task and you want to cancel it if leaving a screen. So in this case I would wrap the task future with CancelableOperation
and I would cancel it onDispose
.
Yeah, you can do that with use.future
, but it has "too much power" for what I want in that case: just a callback being executed on dispose.
And also I will try to PR a use.lock
. Tomorrow...
Don't know if make sense... as it is needed an external dependency. I suppose it doesn't make sense.
So in this case I would wrap the task future with CancelableOperation and I would cancel it onDispose.
I think a use.effect might actually be more correct there, where it’s keyed off the current CancelableOperation. I’d have to see more code tho to be sure.
Don't know if make sense... as it is needed an external dependency.
yea, I’m not really open to effects that add a dependency on another package at the moment. You’re welcome to make your own package of effects though and add the dependency there though
I'm sorry Greg, I just saw your side_effects_test.dart
using flutter_test
package and I don't have time now to learn it.
Really sorry, I just thought this side effect was simple as wrapper on ScrollController
.
I use a lot these side effects but not sure whether you think they must be included in the package.