typed-emitter
Advanced tools
Comparing version 1.4.0 to 1.5.0-from-event
@@ -35,2 +35,3 @@ export type Arguments<T> = [T] extends [(...args: infer U) => any] | ||
emit<E extends keyof Events> (event: E, ...args: Arguments<Events[E]>): boolean | ||
// The sloppy `eventNames()` return type is to mitigate type incompatibilities - see #5 | ||
eventNames (): (keyof Events | string | symbol)[] | ||
@@ -43,4 +44,10 @@ rawListeners<E extends keyof Events> (event: E): Function[] | ||
setMaxListeners (maxListeners: number): this | ||
/** | ||
* required by `FromEvent` | ||
* @see https://github.com/devanshj/rxjs-from-emitter/issues/4#issuecomment-665104646 | ||
*/ | ||
__events: Events | ||
} | ||
export default TypedEventEmitter |
{ | ||
"name": "typed-emitter", | ||
"version": "1.4.0", | ||
"version": "1.5.0-from-event", | ||
"license": "MIT", | ||
@@ -15,3 +15,6 @@ "description": "Strictly typed event emitter interface for TypeScript 3.", | ||
"main": "./types.js", | ||
"types": "./index.d.ts" | ||
"types": "./index.d.ts", | ||
"optionalDependencies": { | ||
"rxjs": "*" | ||
} | ||
} |
@@ -68,2 +68,19 @@ # Typed-Emitter | ||
## RxJS `fromEvent` types inference | ||
The default `fromEvent` from RxJS will return an `Observable<unknown>` for our typed emitter. | ||
This can be fixed by the following code, by replacing the `fromEvent` type with our enhanced one: `FromEvent`: | ||
```ts | ||
import { fromEvent as rxFromEvent } from "rxjs" | ||
import { FromEvent } from "typed-emitter/rxjs" | ||
// The `Observable` typing can be correctly inferenced | ||
const fromEvent = rxFromEvent as FromEvent | ||
``` | ||
Learn more from [rxjs fromEvent compatibility #9](https://github.com/andywer/typed-emitter/issues/9) | ||
for the `fromEvent` compatibility discussions. | ||
## Why another package? | ||
@@ -70,0 +87,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7220
7
69
96
1
2