DEV Community

Cover image for 🐶 SVG and DOM Events: Rx+JSX experiment updates
Kostia Palchyk
Kostia Palchyk

Posted on • Edited on

6 4

🐶 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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
johncarroll profile image
John Carroll

Note that 0.0.7 update lets us pass Observers as event handlers 🔥

That's such a nice way of handling two-way data binding!

Collapse
 
kosich profile image
Kostia Palchyk

Thanks, John!
I'm glad you're keeping your eye on the project 🙂

Yeah, a two-way binding with all the RxJS capabilities!
And more features to come 🙌

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay