DEV Community

loading...

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:

<script>
  import { timer } from 'rxjs'
  let tick = timer(0, 1000)
</script>

<h1>
    I see {$tick} 🐑
</h1>
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))),
    startWith('?')
)
$: console.log(`❤ ${ $animals }`)
// The tracktag thing
Enter fullscreen mode Exit fullscreen mode

And the strong stuff:

<script>
    import { BehaviorSubject } from 'rxjs'

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

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

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