Skip to content
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

Initialize processor in build, prevent reusing same strategy #218

Merged

Conversation

brendenpalmer
Copy link
Contributor

Currently in broccoli-persistent-filter, it's not really possible to use your own state on your subclass of it in the overall bucket cacheKey for a few reasons:

  1. It initializes the persistent strategy on the constructor as part of the super call, then immediately stashes a memoized cache key on the constructor; this makes it difficult to instrument cacheKey with state that you have on your subclass without workarounds.
  2. The persistent strategy object is reused by reference, which causes new instances of broccoli-persistent-filter to clobber properties (namely the caches) on the persistent strategy object.

This PR resolves both of these issues. We now only initialize the processor in build, but we guard it to only do this once; we also shallow clone the strategy object, so we don't unnecessarily reuse it across instances of broccoli-persistent-filter.

@rwjblue rwjblue added the bug label Aug 22, 2022
@rwjblue rwjblue merged commit cc0444d into broccolijs:master Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants