
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
akita-firebase
Advanced tools
Simplify connection between Akita and Firebase
Connect Firebase and Akita :
Toolkit :
ng add @angular/fire
ng add @datorama/akita
npm install akita-firebase
Create a new feature Akita :
ng g akita-schematics:feature todos/todos
Update the service :
import { CollectionService, CollectionConfig } from 'akita-firebase';
@Injectable({ providedIn: 'root' })
@CollectionConfig({ path: 'todos' })
export class TodosService extends CollectionService<TodosState, Todo> {
constructor(db: AngularFirestore, store: TodosStore) {
super(db, store);
}
}
In your component you can now start listening on Firebase :
@Component({
selector: 'app-root',
template: `
<ul>
<li *ngFor="let todo of todos$ | async">{{ todo.label }}</li>
<button (click)="add()">Add todo</button>
</ul>
`
})
export class AppComponent implements OnInit, OnDestroy {
public isAlive = true;
public todos$: Observable<Todo[]>;
constructor(private service: TodosService, private query: TodosQuery) {}
ngOnInit() {
// Subscribe to the collection
this.service
.syncCollection()
.pipe(takeWhile(_ => this.isAlive))
.subscribe();
// Get the list from the store
this.todos$ = this.query.selectAll();
}
// Add to Firestore's todo collection
add() {
this.service.add({ checked: false, label: 'New Todo' });
}
ngOnDestroy() {
// Unsubscribe
this.isAlive = false;
}
}
FAQs
A service to connect Akita and Angular Firestore
The npm package akita-firebase receives a total of 1 weekly downloads. As such, akita-firebase popularity was classified as not popular.
We found that akita-firebase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.