@@ -34,30 +34,48 @@ directory and subdirectories:
3434### Example
3535
3636``` csharp
37- FileStream _fileStream = null ;
38-
39- protected override void OnInitialized ()
37+ @* IsInitialized from base class *@
38+ @if (IsInitialized)
4039{
41- _fileStream = GetFileStream ();
42-
43- // BzAsyncDisposer from base class
44- Disposer .Add (_fileStream );
40+ // render product and reviews
41+ }
42+ else
43+ {
44+ < LoadingSpinner / >
45+ }
46+
47+ @code {
48+
49+ IDisposable ? _someDisposable = null ;
50+ ProductDto ? _product = null ;
51+ List < ProductReviewDto > ? _reviews = null ;
4552
46- var subscription = SubscriptionService .Subscribe (" important-messages" , HandleImportantMessage );
47- // Logger from base class
48- Logger .LogInformation (" Got subscription {SubscriptionId}" , subscription .Id );
49- Disposer .Add (subscription );
53+ protected override async Task OnInitializedAsync ()
54+ {
55+ _someDisposable = GetSomeDisposable ();
56+ _product = await ProductService .GetProductAsync (5 );
57+ _reviews = await ProductService .GetProductReviewsAsync (5 );
58+
59+ // BzAsyncDisposer from base class
60+ Disposer .Add (_someDisposable );
61+
62+ var subscription = SubscriptionService .Subscribe (" important-messages" , HandleImportantMessage );
63+ // Logger from base class
64+ Logger .LogInformation (" Got subscription {SubscriptionId}" , subscription .Id );
65+ Disposer .Add (subscription );
66+
67+ SubscriptionService .ConnectionLost += HandleConnectionLost ;
68+ Disposer .Add (() => SubscriptionService .ConnectionLost -= HandleConnectionLost );
69+ Disposer .Add (SayGoodbyeAsync );
70+ }
5071
51- SubscriptionService .ConnectionLost += HandleConnectionLost ;
52- Disposer .Add (() => SubscriptionService .ConnectionLost -= HandleConnectionLost );
53- Disposer .Add (SayGoodbyeAsync );
54- }
72+ private void HandleConnectionLost (object sender , EventArgs e )
73+ {
74+ ShowReconnectOverlay = true ;
75+ // little simplified method from base class
76+ InvokeAsyncStateHasChanged ();
77+ }
5578
56- private void HandleConnectionLost (object sender , EventArgs e )
57- {
58- ShowReconnectOverlay = true ;
59- // little simplified method from base class
60- InvokeAsyncStateHasChanged ();
6179}
6280```
6381
@@ -71,18 +89,18 @@ With the following methods you can retrieve a component's route (`@page "/this-i
7189Useful if you want to create links to other components and you don't want to have magic strings in your code.
7290
7391``` csharp
74- // returns null for "simple" components or the first defined rounte
92+ // returns the first defined route or null for non-routable components
7593BzComponentTool .TryGetRoute <PotentiallyRoutableComponent >();
7694BzComponentTool .TryGetRoute (typeof (PotentiallyRoutableComponent ));
77- // returns the first defined route or throws for "simple" components
95+ // returns the first defined route or throws for non-routable components
7896BzComponentTool .GetRoute <SomePage >();
7997BzComponentTool .GetRoute (typeof (SomePage ));
8098// returns zero-to-many items
8199BzComponentTool .TryGetRoutes <PageWithMultipleRoutes >();
82100BzComponentTool .TryGetRoutes (typeof (PageWithMultipleRoutes ));
83101```
84102
85- ### GetMenuItem
103+ ### BzMenuItem
86104
87105Use the ` BzMenuItemAttribute ` to specify menu items at component level. \
88106For extra laziness you can use the ` BzComponentTool.GetAllMenuItemsFromAssembly(assembly) ` method :)
0 commit comments