question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events / Observables

See original GitHub issue

I’d be interested in discussing how expected events on observable objects could be described. Here’s a first draft for one possibility based on my understanding of the current structural types:

new Channel({ displayName: String }) => ChannelInstance

interface ChannelInstance {
  displayName: String
}, emits: {
  messageAdded: { body: String, authorId: Number },
  memberJoined: { id: Number }
}

Thoughts?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:48 (33 by maintainers)

github_iconTop GitHub Comments

1reaction
ericelliottcommented, Apr 28, 2016

@tomekwi One of the most important goals for me was to create a standard for documenting APIs that we can use in technical documentation.

We needed a standard, easily machine-readable way to document events, regardless of the listening API.

As for scope creep, I don’t expect early implementations to cover all the features, but event documentation was a must-have feature for me that needed to be in the MVP version. I’m already using it.

1reaction
ericelliottcommented, Apr 18, 2016

This is acceptable to me if everybody else likes it better:

emits: {
  'messageAdded': (body: String, authorId: Number),
  'memberJoined': (id: Number, { Name: String, email: String })
}

I guess that makes sense if you think of it this way:

messageAdded is the name of the callback function with the signature (body: String, authorId: Number).

This fits our existing method syntax:

emits: {
  messageAdded(body: String, authorId: Number),
  memberJoined(id: Number, { Name: String, email: String })
}

I’m not sure if we’ve documented it, but IMO, it should be perfectly legal to use quotes and colons with the method syntax, too:

interface MyCallbacks {
  'messageAdded': (body: String, authorId: Number),
  'memberJoined': (id: Number, { Name: String, email: String })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Observables in Angular
Router.events provides events as observables. You can use the filter() operator from RxJS to look for events of interest, and subscribe to them...
Read more >
Event shape observables - Wikipedia
In high energy physics, event shapes observables are quantities used to characterize the geometry of the outcome of a collision between high energy ......
Read more >
Observable - RxJS
Observables are lazy Push collections of multiple values. ... start an "Observable execution" and deliver values or events to an Observer of that...
Read more >
Listen to any DOM Event using an Observable in Angular
An Observable is simply a function that returns a stream of values over time to an observer. Based on this definition, you can...
Read more >
Overview - ReactiveX
Observable : represents the idea of an invokable collection of future values or events. Observer: is a collection of callbacks that knows how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found