Skip to content

Commit eb8908a

Browse files
committed
[Change] ui: pub/sub instead of send/emit/on
Duplicates were doing no good.
1 parent 0a7dcc1 commit eb8908a

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

dist/select.ui.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,13 +2426,15 @@ class UIInstance {
24262426
// SUBSECTION: Pub/Sub Events
24272427
// ============================================================================
24282428

2429-
// Alias for `pub()`.
2429+
// FIXME: Remove, use pub() instead
24302430
send(event, data) {
2431+
console.warn(`[select.ui] Deprecation: send() is deprecated, use pub() instead`);
24312432
return this.pub(event, data);
24322433
}
24332434

2434-
// Alias for `pub()`.
2435+
// FIXME: Remove, use pub() instead
24352436
emit(event, data) {
2437+
console.warn(`[select.ui] Deprecation: emit() is deprecated, use pub() instead`);
24362438
return this.pub(event, data);
24372439
}
24382440

docs/ref-ui.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ Web component API:
245245
- `unmount()`: Removes the instance's nodes from the DOM.
246246
- `dispose()`: Releases instance resources (runtime listeners, reactive/context subscriptions, child instances) without removing nodes directly.
247247
- `render(data?)`: Forces a re-render of the instance, optionally with new data.
248-
- `send(event, data)` / `pub(event, data)`: Publishes an event upward through the component tree.
249-
- `emit(event, data)`: Alias for `pub(event, data)`.
248+
- `pub(event, data)`: Publishes an event upward through the component tree.
250249
- `on(event, handler)` / `off(event, handler)`: Adds or removes runtime event listeners on the instance.
251250
- `provide(key, value)`: Provides a context value to be consumed by child instances.
252251
- `inject(key, defaultValue?)`: Consumes a context value provided by an ancestor instance.
@@ -657,7 +656,7 @@ const Item = ui(`
657656
</li>
658657
`).does({
659658
name: (self, { name }) => name,
660-
remove: (self, data) => self.send("Remove", data),
659+
remove: (self, data) => self.pub("Remove", data),
661660
});
662661
663662
const List = ui(`<ul out="items"></ul>`)
@@ -746,7 +745,7 @@ const LoginForm = ui("#LoginForm").does({
746745
event ? self.update({ password: event.target.value }) : data.password,
747746
submit: (self, { username, password }, event) => {
748747
event.preventDefault();
749-
self.send("Login", { username, password });
748+
self.pub("Login", { username, password });
750749
},
751750
});
752751
```
@@ -884,7 +883,7 @@ const Button = ui(`
884883
isDisabled: (self, { disabled, loading }) => disabled || loading,
885884
click: (self, data, event) => {
886885
if (!data.disabled && !data.loading) {
887-
self.send("Click", data);
886+
self.pub("Click", data);
888887
}
889888
},
890889
});

docs/ui.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ For icon loading and `<ui-icon>` usage, see [`docs/icons.md`](./icons.md).
4747
- `unmount()`: DOM detachment.
4848
- `dispose()`: Releases instance listeners/subscriptions and child instances.
4949
- `render(data?)`: Rendering engine access.
50-
- `send(event, data)` / `pub(event, data)`: Message passing.
51-
- `emit(event, data)`: Event emission.
50+
- `pub(event, data)`: Publishes an event upward through the component tree.
5251
- `on(event, handler)` / `off(event, handler)`: Dynamic event binding.
5352
- `provide(key, value)` / `inject(key, defaultValue?)`: Context management.
5453

@@ -188,8 +187,7 @@ Dynamic("Badge", { label: "Ready" })
188187
- `instance.unmount()`: Removes the instance's nodes from the DOM.
189188
- `instance.dispose()`: Releases runtime listeners/subscriptions and child instances.
190189
- `instance.render(data?)`: Forces a re-render of the instance, optionally with new data.
191-
- `instance.send(event, data)` / `instance.pub(event, data)`: Publishes an event upward through the component tree.
192-
- `instance.emit(event, data)`: Alias for `pub(event, data)`.
190+
- `instance.pub(event, data)`: Publishes an event upward through the component tree.
193191
- `instance.on(event, handler)` / `instance.off(event, handler)`: Adds or removes runtime event listeners on the instance.
194192
- `instance.provide(key, value)`: Provides a context value to be consumed by child instances.
195193
- `instance.inject(key, defaultValue?)`: Consumes a context value provided by an ancestor instance.

src/js/select.ui.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,13 +2426,15 @@ class UIInstance {
24262426
// SUBSECTION: Pub/Sub Events
24272427
// ============================================================================
24282428

2429-
// Alias for `pub()`.
2429+
// FIXME: Remove, use pub() instead
24302430
send(event, data) {
2431+
console.warn(`[select.ui] Deprecation: send() is deprecated, use pub() instead`);
24312432
return this.pub(event, data);
24322433
}
24332434

2434-
// Alias for `pub()`.
2435+
// FIXME: Remove, use pub() instead
24352436
emit(event, data) {
2437+
console.warn(`[select.ui] Deprecation: emit() is deprecated, use pub() instead`);
24362438
return this.pub(event, data);
24372439
}
24382440

0 commit comments

Comments
 (0)