Skip to content

Instantly share code, notes, and snippets.

@umar-muneer
umar-muneer / faulty-component.ts
Created August 12, 2021 13:03
Keep the Observable alive after error
public class Component {
constructor(private service: Service) {}
handleClick$ = new Subject();
ngOnInit() {
this.handleClick$.pipe(
switchMap(() => {
return this.service.someObservable$;
})
).subscribe(console.log);
// this observable would stop firing as soon as there is an error, subsequent button clicks will not trigger it.
@umar-muneer
umar-muneer / mikro-orm-many-to-many.ts
Last active December 5, 2022 06:11
Mikro-orm Many to Many
@Entity({
tableName: 'folders',
})
export class FolderEntity {
@ManyToMany({
entity: () => Project,
pivotEntity: () => VisionProjectsFolderEntity,
joinColumn: 'folder__id', // this property is important to provide, it is the column where we will go and query the pivot table
})
projects = new Collection<Project>(this);