Skip to content

Argument order in addContextListener overloads complicates implementation #215

Closed
@mattjamieson

Description

@mattjamieson

Area of Issue

[ ] App Directory
[X] API
[ ] Context Data
[ ] Intents
[ ] Use Cases
[ ] Other

Issue Description:

The argument order in the two addContextListener overloads of DesktopAgent complicates implementation.

    addContextListener(handler: ContextHandler): Listener;
    addContextListener(contextType: string, handler: ContextHandler): Listener;

Means you have to use union types to implement in TypeScript:

    addContextListener(a: ContextHandler | string, b?: ContextHandler): Listener {
        var handler = a as ContextHandler;
        var contextType = null;

        if (typeof a !== "function") {
            contextType = a as string;
            handler = b as ContextHandler;
        }

        ...    

I suggest we flip the argument order in the second version:

    addContextListener(handler: ContextHandler): Listener;
    addContextListener(handler: ContextHandler, contextType: string): Listener;

Metadata

Metadata

Assignees

Labels

apiFDC3 API Working GroupbugSomething isn't workingchannels feeds & transactionsChannels, Feeds & Transactions Discussion Group

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions