gaoding-inc / stateshot Goto Github PK
View Code? Open in Web Editor NEW💾 Non-aggressive history state management with structure sharing.
💾 Non-aggressive history state management with structure sharing.
Makes sense since we may make hashFunc
replaceable.
Add a index.d.ts
to support usage in typescript.
Using libs like immer
to replace our hash implementation is promising and trivial. Another options needed.
Snippet for "dumping" history records:
// in chrome console
copy(oldHistoryStore)
// in reproduction page
const data = { ... } // paste
history.$index = data.$index
history.$records = data.$records
history.$chunks = data.$chunks
JSFiddle or Glitch is enough.
1、看了你们这个库的实现原理分析,大致理解是你们这个库应该是快照式撤销重做类库?
2、图片处理涉及到distructive 和 non-destructive操作,还有添加图层类操作,图层与原图一起变换操作等一系列操作,那么用你们这个库怎么实现?或者你们有类似的示例吗?
A history.length
getter makes sense.
Current Behavior
history.push(state).then(() => {
console.log(history.length) // 2
})
history.pushSync(state)
In this case history.length
should be 1 since sync push is expected to clear the pending state.
Current implementation is error-prone.
Rollup need a few more setup but is better in bundle size. It can also fix the webpack require
error.
const history = new History()
const state = { a: 1, b: 2 }
history.pushSync({ ...state })
history.pushSync({ ...state, ...{ a: 2 } })
history.pushSync({ ...state, ...{ a: 3 } });
history.undo();
history.undo();
let r1 = history.get(); // { a: 1, b: 2, children: undefined }
history.pushSync({ ...state, ...{ c: 1 } });
let r2 = history.get();
let r3 = history.length; // 3 应该等于2
history.undo();
let r4 = history.get(); // { a: 1, b: 2, children: undefined }
存在的几点问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.