-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onSet should have function signature void Function(Thing)
#942
Comments
Maybe the It's static rather than per instance, but the builder is passed in, and you could build it to get the new instance. https://github.com/google/built_value.dart/blob/master/end_to_end_test/lib/values.dart#L593 |
I am not sure how to do it with |
Changing onSet function signature from void Function(BuiltValue Thing) {
// do nothing with Thing
// call your zero argument function
build();
} |
Do you want a new |
No, I will have a single instance of |
If there is a single stream, you can use |
It doesn't work because I have to add the rebuilt instance to the static void _finalizeBuilder(LeagueBuilder b) {
NotificationsStore_.streamController.add(b.build()));
} Another problem is that testing can be problematic. Moreover, I had to convert private class NotificationsStore = NotificationsStore_ with _$NotificationsStore;
// ignore: camel_case_types
abstract class NotificationsStore_ extends BaseStore with Store { My purpose is to decouple model classes and stores completely. I want to create a package to add reactivity to // a regular reactive int field in a MobX store:
@observable
int myInt;
// possible annotation with a package
@observable_built_value
MyBuiltValueObject myBuiltValueObject; |
I think it should work to use a static bool _inFinalizer = false;
static void _finalizeBuilder(LeagueBuilder b) {
if (!_inFinalizer) {
_inFinalizer = true;
NotificationsStore_.streamController.add(b.build()));
_inFinalizer = false;
}
} |
What is holding you back from changing function signature other than being a breaking change which will impact limited number of users who can quickly migrate :) |
Doesn't |
This problem also exists with the current state. Changing function signature will not affect the number of UI rebuilds. Anyway, I think it is my job to care about frequent UI rebuilds and I can easily throttle UI rebuilds with stream or other means of transformation. Moreover, people who are using |
I am trying to use
built_value
withMobX
. I will add newthing
to the ObservableStream whenever it is rebuilt. So, onSet should have function signaturevoid Function(Thing)
I am aware of the use case in this issue: #589
There can be a solution to cover both situations or change the function definition because we can throttle rebuilds.
The text was updated successfully, but these errors were encountered: