Created
October 16, 2020 10:41
-
-
Save InfiniteXyy/f15f34c0599a1123aedb54de44219b79 to your computer and use it in GitHub Desktop.
RxJSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fromEvent } from "rxjs"; | |
import { debounceTime, tap } from "rxjs/operators"; | |
const React = { | |
createElement(type, props, ...children) { | |
const operator = type.call(null, props); | |
if (children.length !== 0) { | |
return operator.pipe(...children); | |
} | |
return operator; | |
}, | |
}; | |
const FromEvent = ({ target, event }) => { | |
return fromEvent(target, event); | |
}; | |
const DebounceTime = ({ value }) => { | |
return debounceTime(value); | |
}; | |
const Tap = ({ value }) => { | |
return tap(value); | |
}; | |
export const blackMagicSubject = ( | |
<FromEvent target={document} event="click"> | |
<DebounceTime value={100} /> | |
<Tap value={console.log} /> | |
</FromEvent> | |
); | |
blackMagicSubject.subscribe(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment