Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mutation processing into it's own class #223

Merged
merged 5 commits into from
Jun 6, 2020

Conversation

eoghanmurray
Copy link
Contributor

@eoghanmurray eoghanmurray commented May 26, 2020

This should stand on it's own as a refactor, but is intended as a basis
for exposing the new MutationBuffer object to further outside control e.g.
to 'mute' or batch up mutation emission when the page becomes inactive
from a https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
point of view

@eoghanmurray eoghanmurray changed the title Move mutation processing into it's own object. Move mutation processing into it's own class May 26, 2020
@eoghanmurray
Copy link
Contributor Author

Not currently working; output is producing this:

MutationBuffer.prototype.processMutations = function (mutations) {
   ...
   var _this = this;
   mutations.forEach(this.processMutation);

instead of

mutations.forEach(_this.processMutation);

@eoghanmurray
Copy link
Contributor Author

Ok, working now with the 05334ef commit.

@eoghanmurray
Copy link
Contributor Author

Have solved the bind problem by making all methods use the Arrow function expressions.
Let me know if there's a neater way of doing methods (with the ability to use this) in typescript.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

https://stackoverflow.com/questions/43724426/this-is-undefined-inside-the-foreach-loop

This should stand on it's own as a refactor, but is intended as a basis
for exposing the new MutationBuffer object to further outside control e.g.
to 'mute' or batch up mutation emission when the page becomes inactive
from a https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
point of view
…ffer` object, as otherwise `this` referred to the `MutationObserver` object itself
@Yuyz0112
Copy link
Member

@eoghanmurray The changes look good to me.

If I'm right, this patch is a 1-1 rewrite of the mutation processing code without any new logic and would be the base of the following changes.

Please let me know if I'm wrong. For example, if there are any logical changes to the processing flow and I would like to review that part again.

(I've already go through the patch, but Github's split view was not quite useful for comparing new files and deleted files)

@eoghanmurray
Copy link
Contributor Author

Yes, this mutationClass branch is purely refactoring, and should not have any logical changes. Apologies for delay.

@eoghanmurray
Copy link
Contributor Author

#224 builds on top of this and has the logical changes discussed in #221 .

@Yuyz0112
Copy link
Member

Yuyz0112 commented Jun 6, 2020

@eoghanmurray Thanks for the feedback, I would love to merge this patch and start to review the next one.

@Yuyz0112 Yuyz0112 merged commit 8766335 into rrweb-io:master Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants