šŸ¶ SVG and DOM Events: Rx+JSX experiment updates

kosich

Kostia Palchyk

Posted on December 20, 2019

šŸ¶ SVG and DOM Events: Rx+JSX experiment updates

With 0.0.8 update Recks receives SVG support šŸ–¼

function App() {
  return <svg width="300" height="200" stroke="#16b3ff" fill="white">{
    range(0, 200, animationFrameScheduler).pipe(
      map(r => <circle cx="150" cy="100" r={r / 4} />),
      repeat()
    )
  }</svg>
}

Run this example:

NOTE: you can drag-open the code editor from the left side

Also event Subjects

Note that 0.0.7 update lets us pass Observers as event handlers šŸ”„:

function App() {
  const clicks$ = new Subject();

  const count$ = clicks$.pipe(
    startWith(0),
    scan(acc => ++acc)
  );

  return <button onClick={clicks$}>Clicked {count$} times</button>
}

Run this example:

Try it!

To try Recks locally, run:

git clone https://github.com/recksjs/recks-starter-project.git
cd recks-starter-project
npm i
npm start

Have fun!

ā˜ļø If you want to be the first to hear about project updates ā€” be sure to follow me here, on twitter, or watch the project directly @ github!

The End šŸ•

header photo by Patrick Hendry on Unsplash

šŸ’– šŸ’Ŗ šŸ™… šŸš©
kosich
Kostia Palchyk

Posted on December 20, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related