Tenho o seguinte erro no console ao alterar o texto da classe Mensagem:
Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'text'
at NegotiationController.add (NegotiationController.js:32:24)
at HTMLFormElement.onsubmit (index.html:16:90)
add @ NegotiationController.js:32
onsubmit @ index.html:16
Porém não acontece nenhuma alteração na execução do código. Criação do Bind entre a classe e a view:
#getMessageProxy (view) {
const properties = ['text'];
return new Bind(new Message(), view, properties);
}
Este é o código da classe Bind:
class Bind {
constructor (model, view, props) {
view.update(model);
return ProxyFactory.create(model, props, (model) => {
view.update(model);
});
}
}
Este é o código da classe ProxyFactory:
class ProxyFactory {
static create (object, props, action) {
const proxyParams = {
get (target, prop, receiver) {
if (ProxyFactory.#isFunction(target[prop]) && props.includes(prop)) {
return function () {
Reflect.apply(target[prop], target, arguments);
return action(target);
}
}
return Reflect.get(target, prop, receiver);
},
set (target, prop, value, receiver) {
if (props.includes(prop)) {
target[prop] = value;
return action(target);
}
return Reflect.set(target, prop, value, receiver);
}
}
return new Proxy(object, proxyParams);
}
static #isFunction (value) {
return typeof(Function) === typeof(value);
}
}