Added support for resources of non-persistent refs
This commit is contained in:
parent
305946eca4
commit
ac598fa3a7
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
|
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
|
||||||
import { computed, ComputedRef, ref, Ref, watch } from "vue";
|
import { computed, ComputedRef, isRef, ref, Ref, watch } from "vue";
|
||||||
import { globalBus } from "game/events";
|
import { globalBus } from "game/events";
|
||||||
import { State, persistent } from "game/persistence";
|
import { State, persistent } from "game/persistence";
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ export function createResource<T extends State>(
|
||||||
precision = 0,
|
precision = 0,
|
||||||
small = undefined
|
small = undefined
|
||||||
): Resource<T> {
|
): Resource<T> {
|
||||||
const resource: Partial<Resource<T>> = persistent(defaultValue);
|
const resource: Partial<Resource<T>> = isRef(defaultValue)
|
||||||
|
? defaultValue
|
||||||
|
: persistent(defaultValue);
|
||||||
resource.displayName = displayName;
|
resource.displayName = displayName;
|
||||||
resource.precision = precision;
|
resource.precision = precision;
|
||||||
resource.small = small;
|
resource.small = small;
|
||||||
|
|
Loading…
Reference in a new issue