@ -128,7 +128,8 @@ function notify_if_required(
} else {
if ( options . read _properties . includes ( property ) ) {
( params . length == 0 ? [ null ] : params ) . forEach ( ( param ) => {
const sig = get _signal _for _function ( read _methods _signals , property , param ) ;
// read like methods should create the signal so what on any change to them they get notified
const sig = get _signal _for _function ( read _methods _signals , property , param , true ) ;
get ( sig ) ;
} ) ;
} else {
@ -168,24 +169,37 @@ function notify_read_methods(
} else {
( params . length == 0 ? [ null ] : params ) . forEach ( ( param ) => {
const sig = get _signal _for _function ( read _methods _signals , name , param ) ;
increment_signal ( version _signal , sig ) ;
sig && increment_signal ( version _signal , sig ) ;
} ) ;
}
} ) ;
}
/ * *
* gets the signal for this function based on params . If the signal doesn ' t exist , it creates a new one and returns that
* gets the signal for this function based on params . If the signal doesn ' t exist and create _signal _if _doesnt _exist is not set to true , it creates a new one and returns that
* @ template { boolean } [ TCreateSignalIfDoesntExist = false ]
* @ param { ReadMethodsSignals } signals _map
* @ param { string | symbol | number } function _name
* @ param { unknown } param
* @ param { TCreateSignalIfDoesntExist } [ create _signal _if _doesnt _exist = false ]
* @ returns { TCreateSignalIfDoesntExist extends true ? import ( "#client" ) . Source < boolean > : import ( "#client" ) . Source < boolean > | null }
* /
const get _signal _for _function = ( signals _map , function _name , param ) => {
const get _signal _for _function = (
signals _map ,
function _name ,
param ,
// @ts-ignore: this should be supported in jsdoc based on https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template but doesn't?
create _signal _if _doesnt _exist = false
) => {
/ * *
* @ type { Map < unknown , import ( "#client" ) . Source < boolean >> }
* /
let params _to _signal _map ;
if ( ! signals _map . has ( function _name ) ) {
if ( ! create _signal _if _doesnt _exist ) {
// @ts-ignore
return null ;
}
params _to _signal _map = new Map ( [ [ param , source ( false ) ] ] ) ;
signals _map . set ( function _name , params _to _signal _map ) ;
} else {
@ -199,6 +213,10 @@ const get_signal_for_function = (signals_map, function_name, param) => {
* /
let signal ;
if ( ! params _to _signal _map . has ( param ) ) {
if ( ! create _signal _if _doesnt _exist ) {
// @ts-ignore
return null ;
}
signal = source ( false ) ;
params _to _signal _map . set ( param , signal ) ;
} else {
@ -206,7 +224,7 @@ const get_signal_for_function = (signals_map, function_name, param) => {
* @ type { import ( "#client" ) . Source < boolean > }
* / ( p a r a m s _ t o _ s i g n a l _ m a p . g e t ( p a r a m ) ) ;
}
// @ts-ignore
return signal ;
} ;