@hellotext/hellotext 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/__tests__/hellotext_test.js +3 -3
- package/lib/hellotext.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,10 +188,10 @@ To listen to an event, you can call the `on` method, like so
|
|
|
188
188
|
Hellotext.on(eventName, callback)
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
To
|
|
191
|
+
To remove an event listener, you can call `removeEventListener`
|
|
192
192
|
|
|
193
193
|
```javascript
|
|
194
|
-
Hellotext.
|
|
194
|
+
Hellotext.removeEventListener(eventName, callback)
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
### List of events
|
|
@@ -141,7 +141,7 @@ describe("when session is stored in the cookie", function () {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
describe(".
|
|
144
|
+
describe(".removeEventListener", () => {
|
|
145
145
|
const business_id = "xy76ks"
|
|
146
146
|
|
|
147
147
|
beforeAll(() => {
|
|
@@ -153,7 +153,7 @@ describe(".disconnect", () => {
|
|
|
153
153
|
|
|
154
154
|
it("throws an error when event is invalid", () => {
|
|
155
155
|
expect(
|
|
156
|
-
() => Hellotext.
|
|
156
|
+
() => Hellotext.removeEventListener("undefined-event", () => {})
|
|
157
157
|
).toThrowError()
|
|
158
158
|
});
|
|
159
159
|
|
|
@@ -161,7 +161,7 @@ describe(".disconnect", () => {
|
|
|
161
161
|
const callback = jest.fn()
|
|
162
162
|
|
|
163
163
|
Hellotext.on("session-set", callback)
|
|
164
|
-
Hellotext.
|
|
164
|
+
Hellotext.removeEventListener("session-set", callback)
|
|
165
165
|
|
|
166
166
|
expect(callback).toHaveBeenCalledTimes(0)
|
|
167
167
|
});
|
package/lib/hellotext.js
CHANGED
|
@@ -74,7 +74,7 @@ class Hellotext {
|
|
|
74
74
|
* @param event the name of the event to remove
|
|
75
75
|
* @param callback the callback to remove
|
|
76
76
|
*/
|
|
77
|
-
static
|
|
77
|
+
static removeEventListener(event, callback) {
|
|
78
78
|
if(Event.invalid(event)) { throw new InvalidEvent(event) }
|
|
79
79
|
|
|
80
80
|
this.#eventEmitter.removeSubscriber(event, callback)
|