Skip to content
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

Bug: Support for Symbol for fromEvent #7338

Closed
Lightning00Blade opened this issue Sep 13, 2023 · 0 comments · Fixed by #7339
Closed

Bug: Support for Symbol for fromEvent #7338

Lightning00Blade opened this issue Sep 13, 2023 · 0 comments · Fixed by #7339

Comments

@Lightning00Blade
Copy link

Describe the bug

Node Event Emitter supports Symbol for on/off https://nodejs.org/api/events.html#emitteroneventname-listener.
The current implementation of RxJS can use them as provided the example bellow it's just that the types that are used don't support them.

Expected behavior

Symbols are accepted as types.

Reproduction code

import { fromEvent } from 'rxjs';
import { EventEmitter } from 'node:events';

const emitter = new EventEmitter();
const protectedEvent = Symbol('Emitted');

// Fails  TypeChecking
const sourceOne = fromEvent(emitter, protectedEvent);
// Passes TypeChecking
const sourceTwo = fromEvent(emitter, protectedEvent as unknown as string);

sourceOne.subscribe((val) => console.log(val));
sourceTwo.subscribe((val) => console.log(val));

emitter.emit(protectedEvent, {
  message: 'Hello World',
});

Reproduction URL

No response

Version

7.8.1

Environment

Node: 20.3.1 (should work for 16 LTS and above)

Additional context

This useful so that you can have internal methods not exposed the the user of libary.

demensky added a commit to demensky/rxjs that referenced this issue Sep 13, 2023
Allow passing a value of type `symbol` to `eventName` if
a `NodeStyleEventEmitter` is passed to `source`, according to
[the documentation](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener).

Closes ReactiveX#7338
demensky added a commit to demensky/rxjs that referenced this issue Sep 13, 2023
Allow passing a value of type `symbol` to `eventName` if
a `NodeStyleEventEmitter` is passed to `source`, according to
[the documentation](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener).

Closes ReactiveX#7338
demensky added a commit to demensky/rxjs that referenced this issue Oct 28, 2023
Allow passing a value of type `symbol` to `eventName` if
a `NodeStyleEventEmitter` is passed to `source`, according to
[the documentation](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener).

Closes ReactiveX#7338
demensky added a commit to demensky/rxjs that referenced this issue Oct 29, 2023
Allow passing a value of type `symbol` to `eventName` if
a `NodeStyleEventEmitter` is passed to `source`, according to
[the documentation](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener).

Closes ReactiveX#7338
benlesh pushed a commit that referenced this issue Dec 19, 2023
Allow passing a value of type `symbol` to `eventName` if
a `NodeStyleEventEmitter` is passed to `source`, according to
[the documentation](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener).

Closes #7338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant