[IMP] observer: add set and delete static functions

This rev. add a 'set' and 'delete' static functions to the Observer.
They allow to set or delete (only for objects) properties on
observed objects or arrays.

With this, the 'set' functions in Store and Component are no longer
necessary, so they have been removed.

Closes #138
This commit is contained in:
Aaron Bohy
2019-06-06 09:08:51 +02:00
committed by Géry Debongnie
parent 49baf0de6e
commit d1094f647a
7 changed files with 106 additions and 58 deletions
-18
View File
@@ -152,24 +152,6 @@ describe("basic use", () => {
store.dispatch("someaction");
});
test("set function is given to mutations", async () => {
let updateCounter = 0;
const state = { bertinchamps: "brune" };
const mutations = {
addInfo({ state, set }) {
set(state, "chouffe", "blonde");
}
};
const store = new Store({ state, mutations, actions: {} });
store.on("update", null, () => updateCounter++);
expect(updateCounter).toBe(0);
store.commit("addInfo");
await nextMicroTick();
expect(updateCounter).toBe(1);
expect(store.state).toEqual({ bertinchamps: "brune", chouffe: "blonde" });
});
test("can have getters from store", async () => {
const state = {
beers: {