Skip to content

Commit 37fc79e

Browse files
HamzaFarooq95Hamza Farooq
andauthored
Add OnAfterRenderAsync + readme edits (#4)
Co-authored-by: Hamza Farooq <[email protected]>
1 parent 3c13939 commit 37fc79e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Workshop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ You should see the statistics header toggle on and off based on your feature fla
8282
2. Configure OpenFeature in Extensions file
8383

8484
- Open `src/Garage.ServiceDefaults/Extensions.cs`
85-
- Add OpenFeature services in the `AddFeatureFlags` method
85+
- Add OpenFeature services in the `AddFeatureFlags` method, you can ignore the error for now
8686

8787
3. Implement a Custom Provider
8888

8989
- Create a new class `CustomFeatureProvider` in `src/Garage.ServiceDefaults/Providers`
9090
- Use the `FeatureProvider` flags. Tip: You can copy the dictionary from `FeatureFlags.cs` to start
9191
- Add the provider to the OpenFeature configuration in `Extensions.cs`
9292

93-
4. Replace the IFeatureFlags Implementation
93+
4. Replace the IFeatureFlags depenency injection
9494

95-
- Modify the `IFeatureFlags` interface to use OpenFeature `IFeatureClient`
95+
- Modify the usages of `IFeatureFlags` interface to use OpenFeature `IFeatureClient` instead
9696

9797
5. Make sure to use the UserId in the OpenFeature context
9898

src/Garage.Web/Components/Pages/Home.razor

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686

8787
protected override async Task OnInitializedAsync()
8888
{
89-
// Initialize user ID from local storage
90-
await GetUserId();
91-
9289
try
9390
{
9491
var winnersArray = await WinnersApi.GetAllWinnersAsync();
@@ -103,6 +100,13 @@
103100
}
104101
}
105102

103+
protected override async Task OnAfterRenderAsync(bool firstRender)
104+
{
105+
// Initialize user ID from local storage
106+
await GetUserId();
107+
StateHasChanged();
108+
}
109+
106110
private async Task GetUserId()
107111
{
108112
try

0 commit comments

Comments
 (0)