Skip to content

Instantly share code, notes, and snippets.

@InfiniteXyy
Created October 16, 2020 10:41
Show Gist options
  • Save InfiniteXyy/f15f34c0599a1123aedb54de44219b79 to your computer and use it in GitHub Desktop.
Save InfiniteXyy/f15f34c0599a1123aedb54de44219b79 to your computer and use it in GitHub Desktop.
RxJSX
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