feat(postit): wire Circle + BlogAcl clients in the DI container
App.axaml.cs is the composition root for PostIt. It now also builds and registers: - CircleApiClient (singleton) — backed by the same YavscApiClient and the same blogs base URL as BlogApiClient - BlogAclApiClient (singleton) — same shape - IYavscApiClient -> YavscApiClient mapping (singleton). The concrete class is still resolvable as YavscApiClient; the new registration makes the same instance available as IYavscApiClient so future consumers (and unit tests) can take the interface without coupling to the concrete type. The 3 high-level clients are singletons: they hold no mutable state of their own, just a reference to YavscApiClient and a base URL. Reusing the same instance across requests is what the HttpClient inside YavscApiClient was already designed for.
This commit is contained in:
parent
f835ad42a1
commit
a5887a2387
1 changed files with 6 additions and 1 deletions
|
|
@ -57,6 +57,8 @@ public partial class App : Application
|
|||
|
||||
var api = new YavscApiClient(settings, tokenStore);
|
||||
var client = new BlogApiClient(api, settings.BlogsApiUrl);
|
||||
var circleClient = new CircleApiClient(api, settings.BlogsApiUrl);
|
||||
var blogAclClient = new BlogAclApiClient(api, settings.BlogsApiUrl);
|
||||
|
||||
var services = new ServiceCollection();
|
||||
|
||||
|
|
@ -79,8 +81,11 @@ public partial class App : Application
|
|||
|
||||
// ViewModels
|
||||
services.AddSingleton(settings);
|
||||
services.AddSingleton(api);
|
||||
services.AddSingleton<YavscApiClient>(api);
|
||||
services.AddSingleton<IYavscApiClient>(api);
|
||||
services.AddSingleton(client);
|
||||
services.AddSingleton(circleClient);
|
||||
services.AddSingleton(blogAclClient);
|
||||
services.AddTransient<MainPageViewModel>();
|
||||
services.AddTransient<HomePageViewModel>();
|
||||
services.AddTransient<SignaturePageViewModel>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue