import { from , ObservableInput } from 'rxjs' ; import { isProxy , Ref , ref , toRef , UnwrapRef } from 'vue' ; import { untilUnmounted } from '../operators/until' ; param promise export function refFrom < R > ( promise ) ; param promise param defaultValue export function refFrom < R > ( promise , defaultValue ) ; param value export function refFrom < R > ( arg ) ; param observableInput export function refFrom < R > ( obserableInput ) ; param observableInput param defaultValue export function refFrom < R > ( obserableInput , defaultValue ) ; param state param key export function refFrom < R extends Record < any , any > , K extends keyof R > ( state , key ) ; param value export function refFrom < R > ( arg ) ; param value param defaultValue export function refFrom < R > ( arg , defaultValue ) ; export function refFrom ( arg , subArg ? ) { if ( typeof arg === 'object' ) try { const ref$ = ref ( subArg ) ; untilUnmounted ( from ( arg as any ) ) . subscribe ( { next : value => ref$ . value = value } ) ; return ref$ ; } catch ( _ ) { } return isProxy ( arg ) ? toRef ( arg as Record < any , any > , subArg ) : ref ( arg ) ; }