Message from JavaScript discussions

July 2017

— An Aspect looks like this

Aspect.prototype.execute = function (state) {
return Promise.resolve(state)

Message permanent page


And then I try chaining like this

function Strategy(...aspects) {
this.aspects = aspects;
Strategy.prototype.execute = function (...arguments) {
var curAspect = this.aspects[0].execute(arguments);
for (var loc = 1; loc < this.aspects.length; loc++) {
curAspect = curAspect.then(this.aspects[loc].execute);

— Since then is a cw/cs function it is good for AOP I think

— But looking at that for loop do you think that is a good way to chain?

— Uhm


promises.reduce((final, promise) =>
final.then(promise), Promise.resolve(state));

— Oh drerp I forgot about the high order array functions

— Heh

— Thank you haha

— This will allow two algorithms, diff and clone to be used to make diffClone without changing them at all

Message permanent page

— Ooooh

— The exit of diff can be basically if (isDifferent) and will stop execution if false (therefore not doing a clone operation)

Message permanent page