You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-09-01 21:21:58 +03:00
Add concept of 'sentinel' RoomMembers which watch state at a particular point in time.
New sentinels are only created when the RoomMember state changes, so we don't needlessly deep copy RoomMembers f.e. MatrixEvent. Sentinels co-exist with RoomState.members which are single instances to which listeners can be attached. This gets the best of both worlds (don't have to keep re-attaching listeners on member changes, don't have needless memory consumption).
This commit is contained in:
17
lib/utils.js
17
lib/utils.js
@@ -159,7 +159,22 @@ module.exports.checkObjectHasNoAdditionalKeys = function(obj, allowedKeys) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Deep copy the given object. The object MUST NOT have circular references.
|
||||
* Assigns all the properties in src to dst. If these properties are Objects,
|
||||
* then both src and dst will refer to the same thing.
|
||||
* @param {Object} src The object to copy properties from.
|
||||
* @param {Object} dst The object to write properties to.
|
||||
*/
|
||||
module.exports.shallowCopy = function(src, dst) {
|
||||
for (var i in src) {
|
||||
if (src.hasOwnProperty(i)) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Deep copy the given object. The object MUST NOT have circular references and
|
||||
* MUST NOT have functions.
|
||||
* @param {Object} obj The object to deep copy.
|
||||
* @return {Object} A copy of the object without any references to the original.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user