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

Dispose Module callback #903

Open
bessajonathan opened this issue Sep 20, 2023 · 2 comments
Open

Dispose Module callback #903

bessajonathan opened this issue Sep 20, 2023 · 2 comments
Labels
new New issue request attention question Questions about using some feature or general working of the package

Comments

@bessajonathan
Copy link

I need know when the module was disposed.
How do I do that?

Do exist some callback?

@bessajonathan bessajonathan added new New issue request attention question Questions about using some feature or general working of the package labels Sep 20, 2023
@rafampessoa
Copy link

rafampessoa commented Oct 5, 2023

Good question.

I was trying to do it last week but was unsuccessful.

I wanna know if is possible to know when module is initialized (navigation push) and when is disposed (navigation pop).

@fabricio-godoi
Copy link

fabricio-godoi commented Oct 23, 2023

You can extends Disposable in the module and override the dispose method.

Using Disposable interface

Doing this does not require BindConfig, but creates a link between the package and the class.

class MyController implements Disposable {
  final controller = StreamController();

  @override
  void dispose() {
    controller.close();
  }
}

Source: https://github.com/Flutterando/modular/blob/master/doc/docs/flutter_modular/dependency-injection.md


Edit1: It is supposed to be used in the binds, but you could try to check if it works with Module as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New issue request attention question Questions about using some feature or general working of the package
Projects
None yet
Development

No branches or pull requests

3 participants