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:
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.
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.
Currently in
broccoli-persistent-filter
, it's not really possible to use your own state on your subclass of it in the overall bucketcacheKey
for a few reasons:super
call, then immediately stashes a memoized cache key on the constructor; this makes it difficult to instrumentcacheKey
with state that you have on your subclass without workarounds.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 ofbroccoli-persistent-filter
.