📄 from¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 2 |
| 📦 Imports | 10 |
| 🟢 Vue Composition API | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/rxjs/from/index.ts
📦 Imports¶
| Name | Source |
|---|---|
ObservableInput |
rxjs |
Subscription |
rxjs |
MaybeRef |
vue |
Ref |
vue |
WatchOptions |
vue |
fromEventRx |
rxjs |
fromRxjs |
rxjs |
Observable |
rxjs |
isRef |
vue |
watch |
vue |
Vue Composition API¶
| Name | Type | Reactive Variables | Composables |
|---|---|---|---|
watch |
watch | none | none |
watch |
watch | none | none |
Functions¶
from(value: ObservableInput<T> | Ref<T>, watchOptions: WatchOptions): Observable<T>¶
Parameters:
valueObservableInput<T> | Ref<T>watchOptionsWatchOptions
Returns: Observable<T>
Calls:
isRef (from vue)watch (from vue)subscriber.nextfromRxjs (from rxjs)
Code
fromEvent(value: MaybeRef<T>, event: string): Observable<Event>¶
Parameters:
valueMaybeRef<T>eventstring
Returns: Observable<Event>
Calls:
isRef (from vue)watch (from vue)innerSub?.unsubscribefromEventRx(element, event).subscribesubscriber.addfromEventRx (from rxjs)
Code
export function fromEvent<T extends HTMLElement | null>(value: MaybeRef<T>, event: string): Observable<Event> {
if (isRef<T>(value)) {
return new Observable((subscriber) => {
let innerSub: Subscription | undefined
return watch(value, (element) => {
innerSub?.unsubscribe()
if (element instanceof HTMLElement) {
innerSub = fromEventRx(element, event).subscribe(subscriber)
subscriber.add(innerSub)
}
}, { immediate: true })
})
}
if (value === null) {
throw new Error('The value is `null`, and it should be an HTMLElement.')
}
return fromEventRx(value, event)
}
Generated by Syntax Scribe