Fire Legion
DDD framework to work with Firebase
Includes:
- ORM On Fire - Firestore ORM
- FireRx - RxJS extension that provides async capabilities
ORM On Fire
Delightful Firestore ORM
import { Aggregate, Entity, Collection, CollectionRef, ID, Field } from '@typeheim/orm-on-fire'
@Aggregate()
export class User {
@ID() id: string
@Field() firstName: string
@Field() lastName: string
@Field() status: string
@CollectionRef(UserFile) files: Collection<UserFile>
}
@Entity({collection: 'user-files'})
export class UserFile {
@ID() id: string
@Field()
name: string
}
const Users = Collection.of(User)
let markus = await Users.one('markus').get()
Users.one('tom').get().subscribe((tom: User) => {
tom.files.forEach((file: UserFile) => {
})
})
FireRx
Want Rx.JS to work as promises? Here you go:
import { FireReplaySubject } from '@typeheim/fire-rx'
let subject = new FireReplaySubject<number>(1)
subject.next(5)
let value = await subject
subject.next(6)
let nextValue = await subject