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

feat: add PROVIDER_CONTEXT_CHANGED event (web-sdk only) #731

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Dec 14, 2023

This PR:

  • adds PROVIDER_CONTEXT_CHANGED events, which, in the static paradigm, can be used to inform the SDK that the flags should be re-evaluated (important for UI repaints in React, for instance (note this event is only available in the web-sdk)
  • runs the associated PROVIDER_CONTEXT_CHANGED handlers if the provider's context handler function ran successfully or PROVIDER_ERROR handlers otherwise.
  • adds associated tests

A decent amount of this is just typing magic to reduce duplicated code while making the new event only available in the web-sdk.

See: associated spec change

Fixes: #729

@toddbaert toddbaert requested a review from a team as a code owner December 14, 2023 16:31
@toddbaert toddbaert force-pushed the feat/PROVIDER_CONTEXT_CHANGED branch 4 times, most recently from bf5c706 to c2fb02e Compare December 14, 2023 16:58
packages/client/test/events.spec.ts Outdated Show resolved Hide resolved
packages/client/test/events.spec.ts Outdated Show resolved Hide resolved
packages/client/test/events.spec.ts Outdated Show resolved Hide resolved
@toddbaert
Copy link
Member Author

Great points @beeme1mr , please re-review.

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the lint issues when you have a moment.

packages/client/src/events/events.ts Show resolved Hide resolved
packages/client/src/open-feature.ts Outdated Show resolved Hide resolved
@toddbaert
Copy link
Member Author

Please address the lint issues when you have a moment.

done

Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@toddbaert toddbaert force-pushed the feat/PROVIDER_CONTEXT_CHANGED branch from a78a0e9 to 97d32d5 Compare January 8, 2024 20:13
@toddbaert toddbaert force-pushed the feat/PROVIDER_CONTEXT_CHANGED branch from 97d32d5 to 20c812b Compare January 8, 2024 20:16
Signed-off-by: Todd Baert <[email protected]>
@toddbaert toddbaert added this pull request to the merge queue Jan 8, 2024
Merged via the queue into main with commit 7906bbe Jan 8, 2024
9 checks passed
@toddbaert toddbaert deleted the feat/PROVIDER_CONTEXT_CHANGED branch January 8, 2024 20:21
toddbaert pushed a commit that referenced this pull request Jan 8, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.0.22](core-v0.0.21...core-v0.0.22)
(2024-01-08)


### ✨ New Features

* add PROVIDER_CONTEXT_CHANGED event (web-sdk only)
([#731](#731))
([7906bbe](7906bbe))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Signed-off-by: OpenFeature Bot <[email protected]>
Signed-off-by: openfeature-peer-update-bot <[email protected]>
Co-authored-by: openfeature-peer-update-bot <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jan 8, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.4.9](web-sdk-v0.4.8...web-sdk-v0.4.9)
(2024-01-08)


### ✨ New Features

* add named provider metadata accessor
([#715](#715))
([23d14aa](23d14aa))
* add PROVIDER_CONTEXT_CHANGED event (web-sdk only)
([#731](#731))
([7906bbe](7906bbe))


### 🐛 Bug Fixes

* use in memory provider for e2e suites
([#740](#740))
([696bf4a](696bf4a))


### 🧹 Chore

* **main:** release core 0.0.21
([#720](#720))
([7d1aca4](7d1aca4))
* **main:** release core 0.0.22
([#745](#745))
([a0cc855](a0cc855))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
toddbaert added a commit that referenced this pull request Jan 11, 2024
This PR:

- adds `PROVIDER_CONTEXT_CHANGED` events, which, in the static paradigm,
can be used to inform the SDK that the flags should be re-evaluated
(important for UI repaints in React, for instance (note this event is
only available in the web-sdk)
- runs the associated `PROVIDER_CONTEXT_CHANGED` handlers if the
provider's context handler function ran successfully or `PROVIDER_ERROR`
handlers otherwise.
- adds associated tests

A decent amount of this is just typing magic to reduce duplicated code
while making the new event only available in the web-sdk.

See: [associated spec
change](open-feature/spec#200)

Fixes: #729

---------

Signed-off-by: Todd Baert <[email protected]>
toddbaert pushed a commit that referenced this pull request Jan 11, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.0.22](core-v0.0.21...core-v0.0.22)
(2024-01-08)


### ✨ New Features

* add PROVIDER_CONTEXT_CHANGED event (web-sdk only)
([#731](#731))
([7906bbe](7906bbe))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Signed-off-by: OpenFeature Bot <[email protected]>
Signed-off-by: openfeature-peer-update-bot <[email protected]>
Co-authored-by: openfeature-peer-update-bot <[email protected]>
toddbaert added a commit that referenced this pull request Jan 11, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.4.9](web-sdk-v0.4.8...web-sdk-v0.4.9)
(2024-01-08)


### ✨ New Features

* add named provider metadata accessor
([#715](#715))
([23d14aa](23d14aa))
* add PROVIDER_CONTEXT_CHANGED event (web-sdk only)
([#731](#731))
([7906bbe](7906bbe))


### 🐛 Bug Fixes

* use in memory provider for e2e suites
([#740](#740))
([696bf4a](696bf4a))


### 🧹 Chore

* **main:** release core 0.0.21
([#720](#720))
([7d1aca4](7d1aca4))
* **main:** release core 0.0.22
([#745](#745))
([a0cc855](a0cc855))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jan 11, 2024
#698)

Adds a few react features:

- `<Suspense />` support: components using feature flags will trigger
suspense for easy loaders/spinners
- Ability to specify name for provider scope: `<OpenFeatureProvider
name="my-provider">`

> [!IMPORTANT]  
> Please see
[here](open-feature/react-test-app#2) for the
latest changes to the demo application using these features (note that
we won't be able to merge these demos until this is released).

> [!IMPORTANT]  
> Also note I've added no tests, which is certainly not my MO. I will
add them to this PR once there's an agreement on this behavior and
implementation.

gif from the demo app:


![demo](https://github.com/open-feature/js-sdk/assets/25272906/73007cff-0d0c-44e8-a34c-b99412556206)

:warning: I want to add another feature here to support re-rendering on
context changes. That requires
[this](#731) to be merged.

---------

Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement PROVIDER_CONTEXT_CHANGED event in web-sdk
3 participants