Skip to content

Commit

Permalink
docs(toObserver): fix wrong semantics and missing import (vueuse#3488)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzelleke authored Oct 21, 2023
1 parent aca6a79 commit bacf402
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/rxjs/toObserver/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sugar function to convert a `ref` into an RxJS [Observer](https://rxjs.dev/guide
import { ref } from 'vue'
import { from, fromEvent, toObserver, useSubscription } from '@vueuse/rxjs'
import { interval } from 'rxjs'
import { map, mapTo, takeUntil, withLatestFrom } from 'rxjs/operators'
import { map, mapTo, startWith, takeUntil, withLatestFrom } from 'rxjs/operators'

const count = ref(0)
const button = ref<HTMLButtonElement>(null)
Expand All @@ -23,7 +23,7 @@ useSubscription(
mapTo(1),
takeUntil(fromEvent(button, 'click')),
withLatestFrom(from(count).pipe(startWith(0))),
map(([total, curr]) => curr + total),
map(([curr, total]) => curr + total),
)
.subscribe(toObserver(count)), // same as ).subscribe(val => (count.value = val))
)
Expand Down

0 comments on commit bacf402

Please sign in to comment.