Open jameslaneconkling opened 6 years ago
The following router implementation using observables produces inefficient, disaggregated service calls
const router = new Router([ { route: 'people[{integers:indices}]', get: ({ indices }) => { return from(indices).pipe( map((index) => ({ path: ['people', index], value: { $type: 'ref', value: ['peopleById', `_${index}`] }, // fake index -> id mapping })) ); }, }, { route: 'peopleById[{keys:ids}].name', get: ({ ids }) => { console.log('ids', ids); return from(ids).pipe( map((id) => ({ path: ['peopleById', id, 'name'], value: `Person #${id}`, })) ); }, } ]).subscribe(); // > ids [ '_1' ] // > ids [ '_2' ] // > ids [ '_3' ] // > ids [ '_4' ] // > ids [ '_5' ]
Adding a bufferTime(0) operator correctly keeps synchronous emissions aggregated
bufferTime(0)
const router = new Router([ { route: 'people[{integers:indices}]', get: ({ indices }) => { return from(indices).pipe( map((index) => ({ path: ['people', index], value: { $type: 'ref', value: ['peopleById', `_${index}`] }, })), bufferTime(0), ); }, }, ... ]).subscribe();
Should buffering of synchronous observable responses be the default?
The following router implementation using observables produces inefficient, disaggregated service calls
Adding a
bufferTime(0)
operator correctly keeps synchronous emissions aggregatedShould buffering of synchronous observable responses be the default?