DEV Community

Discussion on: RegExp syntax for Observables: Never Been Easier!

kosich profile image
Kostia Palchyk Author

Hey, Dean!

Yeah! In the second part I'm exploring an operator based approach, where
exec('DM*U' , { D, M, U }) transforms into query(D, some(M), U) (note that some is an operator example). And with that format we potentially could define our custom operators to match particular keydown events. So, I think, with a few tweaks it could look something like this:

let keydown$ = fromEvent(document, 'keydown');
const [up, down] = [38,40].map(code => Operator(keydown$, e => e.key == code));
query(up, up, down, down, /* ... */ )
  .subscribe(() => console.log('CHEATER!!11elf'));
Enter fullscreen mode Exit fullscreen mode