Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcanosantana committed Nov 27, 2023
1 parent dc73678 commit 5c5612f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,35 @@ Here are some of the links I've fund helpful under my entire development:
Having some of previous experiences in *Ionic* and *Angular* I've found some behaviours are really similar, so I decided to make a Service architecture.

A Singleton service for getting user's info is inyected in each page and component that needs it.
The following code was added in the *Program.cs* file, so I could access it:
```
//This Singleton is not static, it's an instance that will be injected across pages
var userService = new UserService();
userService.InitializeDummyDB();
builder.Services.AddSingleton<UserService>(userService);
```
The most interesting thing about blazor is that a Singleton doesn't seem to follow the conventional pattern of ```static``` keyword. It instead inyects it, each inyection accessing to it like if it was an instantiated object.


### 📆 Second/Third day
Having lost a lot of time the first day figuring out how everything worked, the second and third day were faster.
Having lost a lot of time the first day figuring out how everything worked, the second and third day were faster 🏎️
The most difficult thing was creating an Uri having a path, because on localhost and deployment versions would behave differently. Finally made it with this code:

```
private String GetAbsoluteUri()
{
//Detect if it's from localhost or online, change the uri depending of that
String baseUri = NavigationManager.BaseUri.ToString();
if (baseUri.Contains("github.io"))
baseUri += "CirsaHackaton/";
return baseUri + "aff/" + UserService.GetLoggedUser().GetId();
}
```
That code gets path, and if it's from github adds the repo name, that was missing from the default bahaviour.


The final thing was improving a bit the styles, I fought a lot with *Bootstrap* 🤺 and some code bugs.
Also writing this readme 🖍️

0 comments on commit 5c5612f

Please sign in to comment.