Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
NotificationsYou must be signed in to change notification settings

sscholle/zero-angular

Repository files navigation

Angular bindings for Zero.

Dependencies

  • Angular v14-19
  • @rocicorp/zero v0.19
  • RxJs v6-7

Add Zero as Provider

import{Zero}from'@rocicorp/zero';import{provideZero}from'zero-angular/zero.service';...import{schema}from'../util/schema';// import your schema Instance...provideZero(newZero({ schema,server:'http://localhost:4848',userID:'anon'}))...

Inject Services and Use Query

import{ZeroService}from'zero-angular/zero.service';import{QueryService}from'zero-angular/query.service';...import{Schema}from'../util/schema';// import your Schema Type...exportclassMessagesComponentimplementsOnInit{  ...// Inject Services via Constructorconstructor(privatezeroService:ZeroService<Schema>,privatezeroQuery:QueryService){}ngOnInit():void{ths.fetchSync();this.fetchUsingQuerySubscription();}// Example Zero fetch for data that does not need live updatesfetchSync(){this.users=this.zeroService.getZero().query.user.materialize("forever");this.mediums=this.zeroService.getZero().query.medium.materialize("forever");this.allMessages=this.zeroService.getZero().query.message.materialize("forever");}// Subscribe to Query data enabling realtime updatesfetchUsingQuerySubscription(){// Build the Query using the ZeroServiceletquery=this.zeroService.getZero().query.message.related("medium").related("sender").orderBy("timestamp","desc").limit(20);if(this.filterUser){query=query.where("senderID",this.filterUser);}if(this.filterText){query=query.where("body","LIKE",`%${this.filterText}%`);}// Use the Query with the Query Service and Subscribethis.zeroQuery.useQuery(query).subscribe(([results,resultType])=>{console.log('Query Result:',results,resultType);});}  ...}...

Contributing

Building

To build the library, run:

ng build zero-angular

Running unit tests

ngtest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp