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

Observe Creator dispose events #16

Closed
diegosz opened this issue Sep 17, 2022 · 2 comments
Closed

Observe Creator dispose events #16

diegosz opened this issue Sep 17, 2022 · 2 comments

Comments

@diegosz
Copy link

diegosz commented Sep 17, 2022

First, many thanks for this library, like it a lot, I was looking something to migrate away from Getx, was pondering on using Riverpod, but luckily found Creator. It's simple to grasp and easy to onboard a dev team starting with Flutter.

While migrating some controllers, one thing that help me fully understand the lifecycle of the Creator values was using a custom observer that also prints the dispose events because the default observer skips those events.

This post is only to record this so it could help someone else.

The custom observer:

class CustomCreatorObserver extends DefaultCreatorObserver {
  const CustomCreatorObserver();

  @override
  void onDispose(CreatorBase creator) {
    if (ignore(creator)) {
      return;
    }
    print('[Creator] Dispose: ${creator.infoName}');
  }
}

And you could use it like this:

void main() {
  runApp(CreatorGraph(
    child: const MyApp(),
    observer: const CustomCreatorObserver(),
  ));
}

Cheers,
Diego

@liangxianzhe
Copy link
Owner

Thanks for posting this @diegosz, I'm glad Creator could help!

@diegosz diegosz closed this as completed Sep 17, 2022
@liangxianzhe
Copy link
Owner

Hi @diegosz FYI I added more options for logging 28ab50d

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

2 participants