Skip to content

Instantly share code, notes, and snippets.

View e-oz's full-sized avatar
πŸ•ŠοΈ

Evgeniy OZ e-oz

πŸ•ŠοΈ
View GitHub Profile
@e-oz
e-oz / issue-log-83.md
Created January 18, 2020 10:09 — forked from goranmoomin/issue-log-83.md
actix-service Cell::get_mut() is unsound
@e-oz
e-oz / zone-flags.ts
Created July 11, 2022 14:47
zone-flags.ts
/* eslint-disable @typescript-eslint/no-explicit-any */
//
// https://angular.io/guide/zone#setting-up-zonejs
// https://github.com/angular/angular/blob/master/packages/zone.js/lib/zone.configurations.api.ts
//
(window as any).__Zone_disable_defineProperty = true;
(window as any).__Zone_disable_requestAnimationFrame = true;
(window as any).__Zone_disable_on_property = true;
(window as any).__zone_symbol__UNPATCHED_EVENTS = [
// Not so perfect
export class RegStore extends ComponentStore<SomeState> {
private readonly registrationSuccess$ = this.effect(_ => _.pipe(
tap(() => {
this.patchState({success: true});
this.regsCounterAdd$();
})
));
private readonly regsCounterAdd$ = this.effect(_ => _.pipe(
siwtchMap(() => this.regSrv.increaseCounter())
class UploaderConfig {
public readonly url: string;
}
// Service, where you need UploaderConfig
class ApiService {
constructor(@Inject('UPLOADER_CONFIG') config: UploaderConfig){
}
}
// Module or component where you can configure dependencies:
interface UsersListState {
users: User[];
columns: string[];
}
class UsersListStore extends ComponentStore<UsersListState> {
// ...
getUsers() {
return this.select(state => state.users).pipe(
combineLatestWith(this.select(state => state.columns)),
map(([users, columns]) => {
libs/feature/src:
└─ lib
β”œβ”€ example
β”‚ β”œβ”€ example.component.html
β”‚ β”œβ”€ [example.component.scss]
β”‚ β”œβ”€ example.component.spec.ts
β”‚ β”œβ”€ example.component.ts
β”‚ β”œβ”€ [example.store.ts]
β”‚ └─ [README.md]
└─ [README.md]
@e-oz
e-oz / input.ts
Created September 20, 2022 12:32
export class SomeComponent {
@Input() set field(field: someType) {
this.store.patchState({field});
}
}
@e-oz
e-oz / viva-magenta.scss
Created December 2, 2022 11:53
Viva Magenta - Angular Material Palette
$dark-primary-text: rgba(0, 0, 0, 0.87);
$light-primary-text: rgb(255, 255, 255);
$viva-magenta: (
50 : #f7e5e9,
100 : #ebbec8,
200 : #dd93a4,
300 : #cf6780,
400 : #c54764,
500 : #bb2649,
@e-oz
e-oz / main.ts
Created December 26, 2022 13:00
NgZone optimisations for Angular CDK Drag & Drop
platformBrowserDynamic().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true,
ngZoneRunCoalescing: true,
}).catch((err) => console.error(err));
import { assertInInjectionContext, DestroyRef, inject, Injector, isDevMode, isSignal, type Signal } from '@angular/core';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
import { isObservable, Observable, of, retry, type RetryConfig, Subject, Subscription } from 'rxjs';
export type CreateEffectOptions = {
injector?: Injector,
/**
* @param retryOnError
* Set to 'false' to disable retrying on error.
* Otherwise, generated effect will use `retry()`.