You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rpc: Collection deepChange fires once more on every update of an item #765
Each server-side update() of the same item in a returned Collection makes deepChange on the client fire once more than the last time: the n-th update emits n times.
import{entity}from'@deepkit/type';import{Collection,DirectClient,rpc,RpcKernel}from'@deepkit/rpc';
@entity.name('task')classTask{version: number=0;constructor(publicid: number,publictitle: string){}}consttasks=newCollection(Task);
@rpc.controller('tasks')classTaskController{
@rpc.action()list(): Collection<Task>{tasks.set([newTask(1,'write report')]);returntasks;}
@rpc.action()rename(title: string): void{tasks.update([newTask(1,title)]);}}constkernel=newRpcKernel();kernel.registerController(TaskController);constapi=newDirectClient(kernel).controller<TaskController>('tasks');constlist=awaitapi.list();constchanges: string[]=[];list.deepChange.subscribe(task=>changes.push(task.title));for(consttitleof['draft','review','final']){awaitapi.rename(title);awaitnewPromise(resolve=>setTimeout(resolve,10));// let the change arrive}console.log(changes);// actual: ['draft', 'review', 'review', 'final', 'final', 'final'], should be: ['draft', 'review', 'final']
Activity