DEV Community

Discussion on: RxJS Proxy: 3 new features

fkrasnowski profile image
Franciszek Krasnowski

Sorry for not responding for soooooo long 🤡. Shame on me
I don't see much potential in the tracktag thing. I think we should take a broader perspective. I love computed and <$>.
Why? because it makes code terser and paradoxically more explicit. And it's not just my alienated opinion. Those ideas are already implemented in Svelte, which brings increasingly more attention last time.
Some Svelte with RxJs bits:

  import { timer } from 'rxjs'
  let tick = timer(0, 1000)

    I see {$tick} 🐑
Enter fullscreen mode Exit fullscreen mode

The $ prefix auto-subscribes and unsubscribes to Observable. You can also:

let animals = of( '🐒',  '🦆',  '🐋' ).pipe(
    concatMap(a => of(a).pipe(delay(1000))),
$: console.log(`❤ ${ $animals }`)
// The tracktag thing
Enter fullscreen mode Exit fullscreen mode

And the strong stuff:

    import { BehaviorSubject } from 'rxjs'

    let relationship = new BehaviorSubject({ giver: '👩‍🔬', taker: '🐸' })

    The giver is {$relationship.giver || '?'} <br/>
  And the taker is {$relationship.taker || '?'}

Giver <input bind:value={$relationship.giver} /><br />
Taker <input bind:value={$relationship.taker} />
Enter fullscreen mode Exit fullscreen mode

working demo here

I would like to see those ideas beyond Svelte on a more general/agnostic field. Therefore I am looking forward to your work on this topic