symbol-observable | Symbol.observable ponyfill | Reactive Programming library
kandi X-RAY | symbol-observable Summary
kandi X-RAY | symbol-observable Summary
Symbol.observable ponyfill
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of symbol-observable
symbol-observable Key Features
symbol-observable Examples and Code Snippets
Community Discussions
Trending Discussions on symbol-observable
QUESTION
Hi I am newbie in typesript and while I reading redux source code pieces I found the issue and search a lot of stuff and can not track its tail.
...ANSWER
Answered 2021-Mar-26 at 15:59$ and also $$ are valid variable names in javascript with no special meaning whatsoever and thus also have no special meaning in typescript.
QUESTION
I'm trying to type an object that is observable and uses a custom Symbol.observable
ponyfill (similar to the system-observable
ponyfill; code shown below), but I can't figure out a way to do it.
I've tried using typeof $$observable
for the key and tried making Symbol.observable
a unique symbol
, but neither of those worked. I've had to resort to casting the object, but the problem with that approach is that I then have to cast the entire object (not shown below) and that makes it harder to catch other type errors due to other properties in the object being incorrectly typed. I also can't just do ReturnType
because I'd like to have it defined in a separate interface without having to depend on the function.
I would alternatively be interested in knowing if there's a way to cast it on a more fine-grained level than casting the entire object (if it turns out to be impossible to do without casting).
I've provided a playground link. Any help would be appreciated.
First attempt (no casting)
Error message
Property '[Symbol.observable]' is missing in type '{ [x: string]: () => { [x: string]: ((observer: Observer) => { unsubscribe(): void; }) | (() => { [x: string]: ((observer: Observer) => { unsubscribe(): void; }) | ...; subscribe(observer: Observer): { ...; }; }); subscribe(observer: Observer): { ...; }; }; }' but required in type 'Container'.(2741)
Code
...ANSWER
Answered 2020-May-14 at 02:03if you cast the "@@observable"
string to any
, you can type the $$observable
as a unique symbol, which will let you use it as a key for the interfaces:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install symbol-observable
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page