-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue where, in some situations, the immediate-invoker helper manager (used when you use resourceFactory
) was not correctly destroying the previous instance of a resource (such as when args change))
#1135
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Estimated impact to a consuming app, depending on which bundle is imported
|
resourceFactory
) was not correctly destroying the previous instance of a resource (such as when args change))
resourceFactory
) was not correctly destroying the previous instance of a resource (such as when args change))resourceFactory
) was not correctly destroying the previous instance of a resource (such as when args change))
@@ -14,9 +14,6 @@ type ResourceFactory<Value = any, Args = any> = (...args: SpreadFor<Args>) => Va | |||
|
|||
interface State { | |||
cache: ReturnType<typeof invokeHelper>; | |||
fn: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were all unused
let result = invokeHelper(cache, resource); | ||
|
||
if (previous) { | ||
destroy(previous); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fix
@@ -72,6 +78,9 @@ class ResourceInvokerManager { | |||
} | |||
|
|||
getDestroyable({ cache }: State) { | |||
/** | |||
* This is the parent cache, from `createHelper` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with nested caches, I had a hard time knowing which thing I was dealing with when, so I added some context
@@ -186,6 +186,7 @@ export function resource<Value>( | |||
let internalConfig: InternalFunctionResourceConfig<Value> = { | |||
definition: context as ResourceFunction<Value>, | |||
type: 'function-based', | |||
name: 'Resource', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helps with debug output when errors from Glimmer print to the console
|
||
function getDebugName(obj: object) { | ||
if ('name' in obj) { | ||
return `Resource Function: ${obj.name}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helps with debug output when errors from Glimmer print to the console
@@ -42,15 +42,21 @@ | |||
"allowImportingTsExtensions": true, | |||
|
|||
// require extensions | |||
"module": "Node16", | |||
"moduleResolution": "Node16", | |||
// "module": "Node16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes local dev experience
let app = new EmberApp(defaults, { | ||
trees: { | ||
app: sideWatch('app', { watching: [path.join(__dirname, '../ember-resources')] }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allows me to not have to restart the app when I re-compile the addon (which is an injected dependency)
Fix #1134
The issue seems specific to vanilla rendering, where your resource isn't surrounded with an if block.