You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This technique with using a function is nothing special to ember-resources, and can be used with any other data / class / etc as well.
169
171
170
-
Further, if multiple reactive arguments are needed with individual reactive behavior, you may instead decide to have your `resourceFactory` receive an object.
172
+
Further, if multiple reactive arguments are needed with individual reactive behavior, you may instead decide to have your wrapping function receive an object.
171
173
172
174
<details><summary>about resourceFactory</summary>
173
175
174
176
`resourceFactory` is a pass-through function purely for telling ember to
175
177
invoke the underlying resource immediately after invoking the `resourceFactory` function.
176
178
179
+
This is why we don't use its return value: it's the same as what you pass to it.
180
+
177
181
Without `resourceFactory`, ember would need extra internal changes to support primitives that
178
182
don't yet exist within the framework to, by convention, decide to _double-invoke_ the functions.
179
183
@@ -203,7 +207,7 @@ So when authoring a `Clock` that receives these types of function arguments, but
<details><summary>using functions for fine-grained reactivity</summary>
@@ -345,21 +351,19 @@ class Demo {
345
351
346
352
For TypeScript, you may have noticed that, if you're a library author, you may want to be concerned with supporting all usages of resources in all contexts, in which case, you may need to support overloaded function calls.
347
353
348
-
TypeScript does not support overloading anonymous functions, so we need to abstract the callback passed to `resourceFactory` into a named function, which we can then define overloads for.
349
-
350
354
Here is how the overloads for `Compiled`, the resource that represents a dynamically compiled component, provided by `ember-repl`, and used by https://limber.glimdown.com and https://tutorial.glimdown.com.
To see this code in action, [checkout the live demo](https://limber.glimdown.com/edit?c=MQAgMglgtgRgpgJxAUQCYQC4HsEChcAicUWAdgM4YICGGEZIWAZiNSAEpzlYCuCAxnBAYAFrRAI4AB0nk4pDOWEihAIhKUJcQQpBQu5agHM4qrYIgA3OKkalWIAOpwYAZSz8A1nAwgAwmKkpHAANgB0%2BAAG0UYAVkohVnC40FI4vgDeWtx8ggBi1PzYCACeADTZvAJwFYIhISAAviBMCFhQIADkxPAIALSyVYLknQDc%2BAD0AFRTIAAKkhjytgHUQaEgqSHE8hi09PZMOCAwkpaYJSBTE7j8ZJ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