-
Notifications
You must be signed in to change notification settings - Fork 5
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
Documentation for wildcard events #299
Changes from 2 commits
9f239db
1f05f5d
c149bec
469c026
a8a8407
16a4932
b1a5fe8
7fd88b7
5552edb
8008176
30a4092
6cd9d7a
5277712
e81a573
a7a3244
55fc156
519adfc
56466b0
e539e38
b7d6a31
e1bd1ac
8fd40b2
7b1d78f
1e933a1
94c8ac4
39df911
99fa98b
d1cf84c
de97917
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,10 +148,10 @@ function sortPagesByOrderAndTitle(p1, p2) { | |
const o1 = get(p1, 'frontmatter.order', null); | ||
const o2 = get(p2, 'frontmatter.order', null); | ||
|
||
if ((o1 === null || typeof o1 === 'undefined') && o2) { | ||
if ((o1 === null || typeof o1 === 'undefined') && !isNaN(o2)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if o1 or o2 is NaN, then that function returns 1 (because any comparison operation on a NaN value ends up returning also, I don't get the purpose of that test, what does it do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get it, because NaN is not 0 (and what do you mean by broken?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When |
||
return 1; | ||
} | ||
if ((o2 === null || typeof o2 === 'undefined') && o1) { | ||
if ((o2 === null || typeof o2 === 'undefined') && !isNaN(o1)) { | ||
return -1; | ||
} | ||
if (o1 === o2) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
type: page | ||
code: false | ||
title: Wildcard Events | ||
order: 250 | ||
--- | ||
|
||
# Wildcard Events | ||
|
||
Kuzzle allows you to listen to multiple events with a single listener thanks to wildcards (`*`). | ||
|
||
--- | ||
|
||
## Single wildcard | ||
xbill82 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
| Arguments | Type | Description | | ||
| --------- | -------------------------------------------------------------- | -------------------------- | | ||
| `request` | <pre><a href=/plugins/1/constructors/request>Request</a></pre> | The normalized API request | | ||
xbill82 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
With a single wildcard you can listen to all the events triggered by Kuzzle. | ||
|
||
#### Example | ||
|
||
```javascript | ||
this.pipes = | ||
// listener function will be triggered at each event | ||
'*': <function to call> | ||
}; | ||
``` | ||
|
||
--- | ||
|
||
## Name wildcard | ||
|
||
| Arguments | Type | Description | | ||
| --------- | -------------------------------------------------------------- | -------------------------- | | ||
| `request` | <pre><a href=/plugins/1/constructors/request>Request</a></pre> | The normalized API request | | ||
|
||
You can also use wildcards to replace only the name of an event. | ||
|
||
### Naming Template | ||
|
||
The event name is built using the following template: | ||
xbill82 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`<controller>:*` | ||
|
||
- `controller`: API controller name | ||
|
||
#### Example | ||
|
||
```javascript | ||
this.pipes = | ||
// listener function will trigger at each | ||
// events triggered in the document namespace | ||
'document:*': <function to call> | ||
}; | ||
``` | ||
|
||
--- | ||
|
||
## Templated events wildcard | ||
|
||
| Arguments | Type | Description | | ||
| --------- | -------------------------------------------------------------- | -------------------------- | | ||
| `request` | <pre><a href=/plugins/1/constructors/request>Request</a></pre> | The normalized API request | | ||
|
||
Wildcards permit listenening templated events. | ||
|
||
### Naming Template | ||
|
||
The event name is built using the following template: | ||
|
||
`<controller>:<template>*` | ||
|
||
- `controller`: API controller name | ||
- `template`: `before`, `after` or `error` | ||
|
||
#### Example | ||
|
||
```javascript | ||
this.pipes = | ||
// listener function will trigger after each | ||
// events triggered in the document namespace | ||
'document:after*': <function to call> | ||
}; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests failed because mqtt dependency is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the effort and checked: that module is indeed used by the Javascript IoT guide.
devDependencies
part of the package.json fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already be fixed without needing to include the module: https://github.com/kuzzleio/documentation/pull/304/files#diff-594d211f65655f937e62cb7d0f75fb99R16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it should be removed from this project's package.json file.