@@ -35,66 +35,3 @@ export function getCurrentValue<Value>(value: Value | Reactive<Value>): Value {
35
35
36
36
return value ;
37
37
}
38
-
39
- /**
40
- * This is what allows resource to be used without @use.
41
- * The caveat though is that a property must be accessed
42
- * on the return object.
43
- *
44
- * A resource not using use *must* be an object.
45
- */
46
- export function wrapForPlainUsage < Value > ( context : object , builder : Builder < Value > ) {
47
- let cache : Resource < Value > ;
48
-
49
- /*
50
- * Having an object that we use invokeHelper + getValue on
51
- * is how we convert the "function" in to a reactive utility
52
- * (along with the following proxy for accessing anything on this 'value')
53
- *
54
- */
55
- const target = {
56
- get [ INTERMEDIATE_VALUE ] ( ) {
57
- if ( ! cache ) {
58
- cache = builder . create ( ) ;
59
- cache . link ( context ) ;
60
- }
61
-
62
- // SAFETY: the types for the helper manager APIs aren't fully defined to infer
63
- // nor allow passing the value.
64
- return cache . current ;
65
- } ,
66
- } ;
67
-
68
- /**
69
- * This proxy takes everything called on or accessed on "target"
70
- * and forwards it along to target[INTERMEDIATE_VALUE] (where the actual resource instance is)
71
- *
72
- * It's important to only access .[INTERMEDIATE_VALUE] within these proxy-handler methods so that
73
- * consumers "reactively entangle with" the Resource.
74
- */
75
- return new Proxy ( target , {
76
- get ( target , key ) : unknown {
77
- const state = target [ INTERMEDIATE_VALUE ] ;
78
-
79
- assert ( '[BUG]: it should not have been possible for this to be undefined' , state ) ;
80
-
81
- return Reflect . get ( state , key , state ) ;
82
- } ,
83
-
84
- ownKeys ( target ) : ( string | symbol ) [ ] {
85
- const value = target [ INTERMEDIATE_VALUE ] ;
86
-
87
- assert ( '[BUG]: it should not have been possible for this to be undefined' , value ) ;
88
-
89
- return Reflect . ownKeys ( value ) ;
90
- } ,
91
-
92
- getOwnPropertyDescriptor ( target , key ) : PropertyDescriptor | undefined {
93
- const value = target [ INTERMEDIATE_VALUE ] ;
94
-
95
- assert ( '[BUG]: it should not have been possible for this to be undefined' , value ) ;
96
-
97
- return Reflect . getOwnPropertyDescriptor ( value , key ) ;
98
- } ,
99
- } ) as never as Value ;
100
- }
0 commit comments