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

Refactor/invoke module api #54

Merged
merged 21 commits into from
Oct 6, 2022

Conversation

andycall
Copy link
Member

@andycall andycall commented Sep 24, 2022

Resigin Webf Module API

Break Changes

webf.methodChanne's API had been changed.

Before

type MethodHandler = (method: string, args: any[]) => void;
interface MethodChannel {
    addMethodCallHandler(handler: MethodHandler): void;
    removeMethodCallHandler(handler: MethodHandler): void;
    invokeMethod(method: string, ...args: any[]): Promise<string>
}

After

type MethodCallHandler = (args: any[]) => any;
interface MethodChannel {
    addMethodCallHandler(method: string, handler: MethodCallHandler): void;
    removeMethodCallHandler(method: string): void;
    clearMethodCallHandler(): void;
    invokeMethod(method: string, ...args: any[]): Promise<any>
}
  1. Now you can return any JavaScript type of values to dart in the MethodCallHandler handler.
  2. Now webf.methodChannel.invokeMethod can return any types of JavaScript values.
  3. Only one method with the same names could be exist. Multiple handlers support are removed.
  4. Add webf.methodChannel.clearMethodCallHandler() API.

webf.invokeModule API had been changed.

Before

webf.invokeModule(module: string, method: string, params?: Object | null, fn?: (err: Error, data: any) => void) => string;

After

webf.invokeModule(module: string, method: string, params?: any | null, fn?: (err: Error, data: any) => any) => any
  1. Any JavaScript type of values can be returned.
  2. The callback now can return any type of JavaScript values.

webf.addWebfModuleListener API had been changed.

Before

webf.addWebfModuleListener: (fn: (moduleName: string, event: Event, extra: string) => void) => void;

After

webf.addWebfModuleListener: (moduleName: string, fn: (event: Event, extra: any) => any) => void;
  1. The listener callback now can return any type of JavaScript value to Dart.

Others

  1. Remove Native WebF API (deprecated)

@andycall andycall merged commit f0b5859 into refactor/remove_host_class Oct 6, 2022
@liuzitong123a liuzitong123a mentioned this pull request Oct 21, 2022
1 task
@andycall andycall deleted the refactor/invoke_module_api branch June 7, 2023 06:37
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

Successfully merging this pull request may close these issues.

1 participant