@@ -17,7 +17,7 @@ export class Computed<
1717 public config : ComputedConfigInterface ;
1818
1919 // Caches whether the compute function is async
20- private isComuteFunctionAsync ! : boolean ;
20+ public isComputeFunctionAsync ! : boolean ;
2121
2222 // Function to compute the Computed Class value
2323 private _computeFunction ! : ComputeFunctionType < ComputedValueType > ;
@@ -29,7 +29,7 @@ export class Computed<
2929
3030 // Helper property to check whether an unknown instance is a Computed,
3131 // without importing the Computed itself for using 'instanceof' (Treeshaking support)
32- public isComputed = true ;
32+ public readonly isComputed = true ;
3333
3434 /**
3535 * A Computed is an extension of the State Class
@@ -70,7 +70,7 @@ export class Computed<
7070
7171 config = defineConfig ( config , {
7272 computedDeps : [ ] ,
73- autodetect : ! this . isComuteFunctionAsync ,
73+ autodetect : ! this . isComputeFunctionAsync , // 'isComputeFunctionAsync' will be set by assigning 'computeFunction'
7474 } ) ;
7575 this . agileInstance = ( ) => agileInstance ;
7676 this . config = {
@@ -106,12 +106,14 @@ export class Computed<
106106 * Assigns a new compute function to the Computed State
107107 * and checks whether it's async.
108108 *
109- * @public
109+ * To update the compute function properly use 'updateComputeFunction()'!
110+ *
111+ * @internal
110112 * @param value - New compute function.
111113 */
112114 public set computeFunction ( value : ComputeFunctionType < ComputedValueType > ) {
113115 this . _computeFunction = value ;
114- this . isComuteFunctionAsync = isAsyncFunction ( value ) ;
116+ this . isComputeFunctionAsync = isAsyncFunction ( value ) ;
115117 }
116118
117119 /**
@@ -180,25 +182,25 @@ export class Computed<
180182 public async compute (
181183 config : ComputeConfigInterface = { }
182184 ) : Promise < ComputedValueType > {
183- if ( config . autodetect && this . isComuteFunctionAsync ) {
184- logCodeManager . log ( '19:00:01 ' ) ;
185+ if ( config . autodetect && this . isComputeFunctionAsync ) {
186+ logCodeManager . log ( '19:02:00 ' ) ;
185187 }
186- return this . isComuteFunctionAsync
188+ return this . isComputeFunctionAsync
187189 ? this . computeAsync ( )
188190 : this . computeSync ( config ) ;
189191 }
190192
191193 /**
192194 * Recomputes the value and ingests it into the runtime.
193195 *
194- * @public
196+ * @internal
195197 * @param config - Configuration object
196198 */
197199 public computeAndIngest (
198200 // https://www.reddit.com/r/learnjavascript/comments/q5rvux/pass_parent_config_object_directly_into_child/
199201 config : StateIngestConfigInterface & ComputeConfigInterface = { }
200202 ) {
201- if ( this . isComuteFunctionAsync ) {
203+ if ( this . isComputeFunctionAsync ) {
202204 this . computeAsync ( ) . then ( ( result ) => {
203205 this . observers [ 'value' ] . ingestValue ( result , config ) ;
204206 } ) ;
@@ -312,7 +314,7 @@ export interface CreateComputedConfigInterface<ComputedValueType = any>
312314 *
313315 * @default undefined
314316 */
315- initialValue ?: ComputedValueType ;
317+ initialValue ?: Awaited < ComputedValueType > ; // https://stackoverflow.com/questions/48944552/typescript-how-to-unwrap-remove-promise-from-a-type
316318}
317319
318320export interface ComputedConfigInterface {
0 commit comments