Comments (3)
Those were supposed to be async. I think they were introduced at the same time as we made the rest of the API async and this probably went in at around the same time or just before and no one noticed the discrepency - I'm suprised nobody's brought it up befor enow. We should fix it for consistency, but it'd require a vote. Alternatively we could deprecate these and introduce some new async versions? Perhaps use the addEventListener
pattern instead so we only need 2 functions (addEventListener and disconnect)?
from fdc3.
So to make that a concrete proposal:
we could change:
interface PrivateChannel extends Channel {
// methods
onAddContextListener(handler: (contextType?: string) => void): Listener;
onUnsubscribe(handler: (contextType?: string) => void): Listener;
onDisconnect(handler: () => void): Listener;
disconnect(): void;
}
to:
interface PrivateChannel extends Channel {
addEventListener(type: PrivateChannelEventType | null, handler: EventHandler): Promise<Listener>;
disconnect(): Promise<void>;
// deprecated methods
/** @deprecated use `addEventListener("addContextListener", handler)` instead. */
onAddContextListener(handler: (contextType?: string) => void): Listener;
/** @deprecated use `addEventListener("unsubscribe", handler)` instead. */
onUnsubscribe(handler: (contextType?: string) => void): Listener;
/** @deprecated use `addEventListener("disconnect", handler)` instead. */
onDisconnect(handler: () => void): Listener;
}
export enum PrivateChannelEventType {
ADD_CONTEXT_LISTENER = "addContextListener"
UNSUBSCRIBE = "unsubscribe"
DISCONNECT = "disconnect"
}
2.2 would actually be good time to do that as we're introducing addEventListener
to the DesktopAgent API, fixing a second consistency issue!
from fdc3.
PrivateChannel.disconnect()
is probably another candidate for this. It's an async process with a PrivateChannelDisconnectRequest
and PrivateChannelDisconnectResponse
so we should be returning a promise IMHO
from fdc3.
Related Issues (20)
- Client-side example mistakenly refer to wrong name "symbol" in PrivateChannel doc HOT 4
- Merge api/ref/types and api/ref/metadata pages and correct links, including from generated context docs HOT 1
- Another Duplicate Name HOT 2
- Add property to support analytics across apps HOT 3
- Standardize the representation of currency pairs by fdc3.instrument HOT 7
- Standard WG Meeting - July 25th, 2024 HOT 10
- Adding Event Listeners on Private Channel HOT 1
- Bug or Inconsistency? HOT 1
- Question: AddContextListenerResponsePayload does not contain channelId HOT 2
- FDC3 monorepo HOT 2
- Use Cases and Workflows Discussion Group - 1st August 2024 HOT 5
- Make Listener.unsubscribe() async for consistency HOT 7
- Simplify Web Connection Protocol HOT 7
- IFramePositioning HOT 2
- RaiseIntentResultResponse HOT 3
- Question: resolvers / channel selectors UI HOT 5
- Spelling Error: FindIntentsByContextsResponse HOT 1
- broadcastEvent on no channel
- Adding Channel State For JoinUserChannel / AddContextListener
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fdc3.