[GH-ISSUE #4] Proxy array.forEach iterates over unproxied values #6

Closed
opened 2026-05-23 08:36:14 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @appy-one on GitHub (Mar 4, 2021).
Original GitHub issue: https://github.com/appy-one/acebase-core/issues/4

Originally assigned to: @appy-one on GitHub.

When using a live data proxy, forEach on an array value will iterate over the underlying (unproxied) values, which is unexpected behaviour.

Example:

const defaultChatValue = { 
   title: 'Members is an Array with objects',
   description: 'Which is not recommended, but should work anyway',
   members: [{ name: 'Ewout', lastOnline: new Date() }] 
};
const proxy = await db.ref('chats/chat1').proxy(defaultChatValue);
const chat = proxy.value;
chat.members.forEach(member => {
   // member is unproxied by forEach on the members array
   if (member.name === 'Ewout') {
      member.lastOnline = new Date(); // Won't trigger db update!! 😱
   }
});
Originally created by @appy-one on GitHub (Mar 4, 2021). Original GitHub issue: https://github.com/appy-one/acebase-core/issues/4 Originally assigned to: @appy-one on GitHub. When using a live data proxy, forEach on an array value will iterate over the underlying (unproxied) values, which is unexpected behaviour. Example: ```js const defaultChatValue = { title: 'Members is an Array with objects', description: 'Which is not recommended, but should work anyway', members: [{ name: 'Ewout', lastOnline: new Date() }] }; const proxy = await db.ref('chats/chat1').proxy(defaultChatValue); const chat = proxy.value; chat.members.forEach(member => { // member is unproxied by forEach on the members array if (member.name === 'Ewout') { member.lastOnline = new Date(); // Won't trigger db update!! 😱 } }); ```
gitea-mirror 2026-05-23 08:36:14 -06:00
Author
Owner

@appy-one commented on GitHub (Mar 8, 2021):

This also applies to array methods like every, some, filter, map , reduce, find etc.

Example, array.find returns unproxied value:

const ewout = chat.members.find(member => member.name === 'ewout');
ewout.lastOnline = new Date(); // Won't trigger update either
<!-- gh-comment-id:792692005 --> @appy-one commented on GitHub (Mar 8, 2021): This also applies to array methods like ```every```, ```some```, ```filter```, ```map``` , ```reduce```, ```find``` etc. Example, ```array.find``` returns unproxied value: ```js const ewout = chat.members.find(member => member.name === 'ewout'); ewout.lastOnline = new Date(); // Won't trigger update either ```
Author
Owner

@appy-one commented on GitHub (Mar 9, 2021):

Released fixes and additions in acebase-core v1.2.0

<!-- gh-comment-id:794364286 --> @appy-one commented on GitHub (Mar 9, 2021): Released fixes and additions in acebase-core v1.2.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-core#6
No description provided.