Skip to content

[MOB-16285] Get latest non pending shared state#800

Merged
cdhoffmann merged 14 commits intoadobe:dev-v3.5.1from
cdhoffmann:getLatestNonPendingSharedState
May 9, 2022
Merged

[MOB-16285] Get latest non pending shared state#800
cdhoffmann merged 14 commits intoadobe:dev-v3.5.1from
cdhoffmann:getLatestNonPendingSharedState

Conversation

@cdhoffmann
Copy link
Copy Markdown
Contributor

@cdhoffmann cdhoffmann commented Apr 29, 2022

In order to allow extensions to read cached config until the remote config is downloaded, a new API has been added to the ExtensionRuntime which allows us to fetch the latest .set shared state before an event.

In order to support this new API, we have added a new parameter to the ExtensionRuntime's getSharedState method, namely resolution: SharedStateResolution which is a new public Enum which currently holds the following values: .lastSet and .any. The API has a default parameter of resolution set to .any which will therefore not break compatibility.

NOTE: If you are using a TestableExtensionRuntime in your Extension, you will need to update it to use the new api though.

In order to read the cached config until the remote config is downloaded, simply set the resolution parameter to .lastSet in your extension. This will get the last set sharedState which will contain the cachedConfig.

@cdhoffmann cdhoffmann requested a review from praveek April 29, 2022 19:11
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 29, 2022

Codecov Report

Merging #800 (f9a205e) into dev-v3.5.1 (1e5a30a) will decrease coverage by 0.06%.
The diff coverage is 76.00%.

@@              Coverage Diff               @@
##           dev-v3.5.1     #800      +/-   ##
==============================================
- Coverage       87.90%   87.85%   -0.06%     
==============================================
  Files             129      129              
  Lines            5671     5694      +23     
==============================================
+ Hits             4985     5002      +17     
- Misses            686      692       +6     

@cdhoffmann cdhoffmann requested review from emdobrin and kevinlind May 3, 2022 15:36
Copy link
Copy Markdown
Contributor

@kevinlind kevinlind left a comment

Choose a reason for hiding this comment

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

Can you add test cases to cover the lines marked by Codecov as not covered?

Copy link
Copy Markdown
Contributor

@kevinlind kevinlind left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Copy Markdown
Contributor

@pfransenadb pfransenadb left a comment

Choose a reason for hiding this comment

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

👍

@cdhoffmann cdhoffmann merged commit cd5dc4e into adobe:dev-v3.5.1 May 9, 2022
@cdhoffmann cdhoffmann deleted the getLatestNonPendingSharedState branch May 9, 2022 16:21
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.

3 participants