Angular bindings for Zero.
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'}))...
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);});} ...}...