pull/9799/head
Rich Harris 3 years ago
parent a79d9e6092
commit ed6e1c0be6

@ -239,6 +239,12 @@ const handler = {
}
};
/** @param {any} object */
export function observe(object) {
const metadata = object[STATE_SYMBOL];
if (metadata) get(metadata.v);
}
if (DEV) {
handler.setPrototypeOf = () => {
throw new Error('Cannot set prototype of $state object');

@ -27,7 +27,6 @@ import {
get,
is_signal,
push_destroy_fn,
set,
execute_effect,
UNINITIALIZED,
derived,
@ -36,13 +35,11 @@ import {
flushSync,
safe_not_equal,
current_block,
source,
managed_effect,
push,
current_component_context,
pop,
unwrap,
mutable_source
unwrap
} from './runtime.js';
import {
current_hydration_fragment,
@ -57,12 +54,11 @@ import {
get_descriptors,
is_array,
object_assign,
object_entries,
object_keys
} from './utils.js';
import { is_promise } from '../common.js';
import { bind_transition, trigger_transitions } from './transitions.js';
import { STATE_SYMBOL, proxy } from './proxy/proxy.js';
import { observe, proxy } from './proxy/proxy.js';
/** @type {Set<string>} */
const all_registerd_events = new Set();
@ -2540,8 +2536,7 @@ export function rest_props(props_signal, rest) {
return derived(() => {
var props = unwrap(props_signal);
const metadata = props[STATE_SYMBOL];
if (metadata) get(metadata.v);
observe(props);
/** @type {Record<string, unknown>} */
var rest_props = {};

@ -4,7 +4,7 @@ import { EMPTY_FUNC, run_all } from '../common.js';
import { get_descriptor, get_descriptors, is_array } from './utils.js';
import { PROPS_CALL_DEFAULT_VALUE, PROPS_IS_IMMUTABLE, PROPS_IS_RUNES } from '../../constants.js';
import { readonly } from './proxy/readonly.js';
import { STATE_SYMBOL } from './proxy/proxy.js';
import { observe } from './proxy/proxy.js';
export const SOURCE = 1;
export const DERIVED = 1 << 1;
@ -1463,8 +1463,7 @@ export function prop_source(props_obj, key, flags, default_value) {
sync_effect(() => {
const props = is_signal(props_obj) ? get(props_obj) : props_obj;
const metadata = props[STATE_SYMBOL];
if (metadata) get(metadata.v);
observe(props_obj);
// Before if to ensure signal dependency is registered
const propagating_value = props[key];

Loading…
Cancel
Save