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

Add unregisterMethod for Server #107

Open
jeiea opened this issue Nov 14, 2023 · 1 comment
Open

Add unregisterMethod for Server #107

jeiea opened this issue Nov 14, 2023 · 1 comment

Comments

@jeiea
Copy link

jeiea commented Nov 14, 2023

Motivation

While writing my flutter app's initialization / cleanup state, I found this.

Currently registerMethod throws if same method name is registered already.

  void registerMethod(String name, Function callback) {
    if (_methods.containsKey(name)) {
      throw ArgumentError('There\'s already a method named "$name".');
    }

    _methods[name] = callback;
  }

I thought about writing code to unregister and re-register methods based on the state of the app. But it wasn't easy due to this.

Can this be considered?

Alternatives

I think registerMethod may return disposer callback.

@natebosch
Copy link
Member

I don't know all the potential impacts of a unregisterMethod. I think a safer change could be to add an overrideMethod which skips the contains(key), though I haven't thought through all the implications, or whether adding method is breaking change.

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