Closed alexanderkroneis closed 4 months ago
I think this should be something like RetrievingFeature
and ResolvingFeature
. /cc @timacdonald
@alexanderkroneis, could you show me how you would achieve what you want to do now that these events are present?
I have another feature for Pennant that I think might be better suited, but I wanted to make sure I understood what you were trying to do first.
Sure. We'll add the trait PurgeFeatures
to the Pennant features we'd like to purge regularly. After RetrievingFeature
has been dispatched we catch it in our PurgeFeaturesListener
and check if the trait exists for the given feature and if so, we check if resolve
is true
. If so, we purge the specific feature.
By this way we avoid to purge the feature every night even tho it's not necessary to purge it yet.
cc @timacdonald
I renamed the events as suggested by Taylor. Let me know if there's anything I can provide to get this PR merged.
cc @timacdonald @taylorotwell
@alexanderkroneis, I would like to propose a different approach for the functionality you are trying to achieve.
Could you please review https://github.com/laravel/pennant/pull/111 and let me know your thoughts and if it will serve your usecase?
I'll close this one for now as I feel that it does. We can open it if it does not work for you.
This PR introduces two events.
RetrieveFeature
is dispatched before the value is retrieved andResolveFeature
is dispatched before the feature is resolved.A real life example. We are using
Pennant
to enable and disable our features conditionally based on a specific date. For example we want to enable a Chat after 1st of July. For this use case we'd like to listen toRetrieveFeature
to check if it's a date-related feature and purge it on the fly.It addresses https://github.com/laravel/pennant/issues/41.