Skip to content
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

MobX Generator - Simplify writing store code (Realm dart example) #890

Open
mohachouch opened this issue Dec 29, 2022 · 2 comments
Open
Assignees

Comments

@mohachouch
Copy link

mohachouch commented Dec 29, 2022

Hello, Thanks for your work.

Writing a store is too verbose. The Realm team generates the class this way. Is it possible to take inspiration from what they have done?

From

class Counter = CounterBase with _$Counter;

abstract class CounterBase with Store {
}

To

class _Counter with Store {
}

After the generator create this :

class Counter extends _Counter {
}

Here is the sample realm repository
https://github.com/realm/realm-dart/tree/main/example/bin

Thanks

@amondnet amondnet self-assigned this Jan 25, 2023
@mohachouch
Copy link
Author

@amondnet what do you think, about this ?

@s0nerik
Copy link
Contributor

s0nerik commented Jan 31, 2023

Let's consider the code navigation in IDE as well. Currently, in order to make IDE navigate to our own code for the state store, and not the generated one, we always use the generated store cast to the original (non-generated) type.

The author's example makes the _Counter private so that the generated Counter is the type to be used.

I'd prefer to have the ability to specify a non-private abstract class as a base type for state store generation. Something like this:

abstract class Counter with Store {
}

and its generated counterpart:

class CounterStore extends Counter {
}

This way, I'd be able to create a Counter using the CounterStore() constructor but expose it using the original Counter type and have proper code navigation in the IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants