Skip to content

Commit

Permalink
refactor: better variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 27, 2020
1 parent 066ba82 commit e43f593
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ export function isRef(r: any): r is Ref {
return r ? r._isRef === true : false
}

export function ref<T extends Ref>(raw: T): T
export function ref<T>(raw: T): Ref<T>
export function ref<T extends Ref>(value: T): T
export function ref<T>(value: T): Ref<T>
export function ref<T = any>(): Ref<T>
export function ref(raw?: unknown) {
if (isRef(raw)) {
return raw
export function ref(value?: unknown) {
if (isRef(value)) {
return value
}
raw = convert(raw)
value = convert(value)

if (__SSR__) {
return {
_isRef: true,
value: raw
value
}
}

const r = {
_isRef: true,
get value() {
track(r, TrackOpTypes.GET, 'value')
return raw
return value
},
set value(newVal) {
raw = convert(newVal)
value = convert(newVal)
trigger(
r,
TriggerOpTypes.SET,
Expand Down

0 comments on commit e43f593

Please sign in to comment.