Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Implement support for notification namespaces #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

koden-km
Copy link
Contributor

Fixes #9

@koden-km
Copy link
Contributor Author

koden-km commented Oct 12, 2017

Not sure how much to describe for listen/unlisten in the docs. There didn't seem to be much to mention in the end.


> *`void`* [**`session.listen`**](#session.listen) `(...namespaces)`

Listens to notifications on the given `namespaces` variable argument list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to include info about why you need to call listen in the first place, and talk about how it is safe to call listen with a namespace you're already listening to etc. etc.

The "Managed module usage" section of the docs also makes use of notifications, and we probably need to update that to show that you have to listen to the appropriate namespace as well.


> *`void`* [**`session.unlisten`**](#session.unlisten) `(...namespaces)`

Unlistens from notifications on the given `namespaces` variable argument list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, we probably need to make note of the fact that you can call unlisten safely with namespaces that you're not already listening to.

type
],
[[{type: type, payload: payload}]]
[[{namespace: namespace, type: type, payload: payload}]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess for consistency, we should probably log listens and unlistens more like this. That is, we don't JSON.stringify(), but rather log the values directly, as a "secondary".

var namespaces = header[0]

if (!Array.isArray(namespaces)) throw new Error('Invalid NOTIFICATION_LISTEN message header (namespaces).')
namespaces.map(function (namespace) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use forEach, instead of map, as we're not actually intending to build a new array.

var namespaces = header[0]

if (!Array.isArray(namespaces)) throw new Error('Invalid NOTIFICATION_UNLISTEN message header (namespaces).')
namespaces.map(function (namespace) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, replace map with forEach.

@koden-km
Copy link
Contributor Author

Changes made based on review comments.

@koden-km koden-km dismissed ezzatron’s stale review October 29, 2017 08:59

Need new review since changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants