Skip to content

Instantly share code, notes, and snippets.

View ahmedalejo's full-sized avatar

Ahmed Alejo ahmedalejo

  • Openalmz
  • Porto Alegre, Brazil
View GitHub Profile
@ahmedalejo
ahmedalejo / INotifyPropertyChangedExtensions.cs
Last active February 18, 2024 18:29
INotifyPropertyChanged Reactive Extensions
/* Originally from https://github.com/ahmedalejo/System.Reactive.EventStream/blob/master/src/Extensions/INotifyPropertyChangedExtensions.cs */
// Sample Usage
component
.ObservePropertyChangedValues(component => component.UXScore)
.Throttle(TimeSpan.FromSeconds(1))
.Subscribe(uXScore => Console.WriteLine($"Component's UX-Score is currently '{uxScore}'"));
component
.ObservePropertyChangedValues()
@ahmedalejo
ahmedalejo / task.ts
Last active December 17, 2023 00:07
Simple Typescript Task.delay(...) analogous to C#
/**
* A class that provides ways for working with async code
* ```ts
* import { Task } from 'task'
* await Task.delay(1000);
* ```
*/
export class Task {
/**
* Creates a Task that will be completed after a time delay.
@ahmedalejo
ahmedalejo / HttpLoggingHandler.cs
Last active October 6, 2024 18:15
C#: Enable unobtrusive HttpClient request-response logging
//Original share here https://github.com/reactiveui/refit/issues/258#issuecomment-243394076 on Aug 30, 2016
//var httpClient = new HttpClient(new HttpLoggingHandler()){ BaseAddress = /**/};
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
@ahmedalejo
ahmedalejo / ViewModelBase.cs
Last active November 23, 2023 23:27
Better Maui - Xamarin Forms Uri/QueryParameter based Navigation via IQueryAttributable
//https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.iqueryattributable
void IQueryAttributable.ApplyQueryAttributes(IDictionary<string, string> query)
{
if (query.Count == 0)
return;
JsonConvert.PopulateObject(
value: JObject.FromObject(query).ToString(),
target:this);
}
@ahmedalejo
ahmedalejo / ViewModel.cs
Last active November 17, 2020 12:16
A Xamarin.Insights Method Decorator using Fody´s MethodDecoratorEx plugin
using static Duration;
public class LogginViewModel
{
[ReportDuration(LongerThan = 1000)]
[ReportDuration("User Login", LongerThan = 1000)]
[ReportSlowExecution(LongerThan = FiveSeconds)]
async Task<bool> LoginAsync() { ... }
}