1.0.0-beta.6 • Published 1 year ago
@runafe/observable-slim v1.0.0-beta.6
Fork of observable-slim
purpose
For version control of our own low code platform based on vue3
changes
refactor with Typescript
batch array changes into one
- if array operation is oneof
push
,pop
,unshift
,shift
,splice
, we always want the final array and initial array, unfortunately,observable-slim
based onProxy
always invoke many changs likearray.0
,array.1
,array.length
which we don't care anymore, so, I rewrite the origin methodspush, unshift, pop, shift, sort, splice, reverse
, thenchange
is just determined by the result and diff bydiffTwoArray
method.
- if array operation is oneof
const app = [
{
itemId: "appOne",
code: 1,
name: 2,
array1: [
{ itemId: 11, name: "1-1" },
{ itemId: 22, name: "1-2" },
],
},
];
const appProxy = ObservableSlim.create(app, false, (change) => {
if (change.length) {
console.log("change", change[0]);
}
});
const [app] = appReactive;
app.array1.reverse();
app.array1.reverse();
app.array1[0].name = "1-1-2";
app.array1.splice(0, 0, { name: "1-3", itemId: ++index });
delete app.array1[0];
- add
__F_
prefix to all private key added byobservable-slim
, like__length
,__isProxy
,__getPath
- change some key for our own project to use
export interface Change {
isSame: boolean;
operationType: OperationTypeEnum;
operation?: ArrayOperation | string;
newValue: any;
oldValue: any;
target: any;
proxy: any;
dotPath: string;
fieldIndex: string; // itemIdPath
property: string;
elementIndex?: number;
sort: number;
}
- add
sort
flag for sorting changes - add more
types
for TS
1.0.0-beta.6
1 year ago
1.0.0-beta.5
1 year ago
1.0.0-beta.4
1 year ago
1.0.0-beta.3
1 year ago
1.0.0-beta.2
2 years ago
1.0.0-beta.1
2 years ago