You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hackape edited this page Jul 19, 2017
·
2 revisions
File
File is the data model for an abstract file, which can map to a real file, a temp file, or a lib, etc.
interfaceFile{constructor(fileProps: FileProps): Fileupdate(fileProps: FileProps): voidname: string// the display name of file, usually the last part on path componentspath: string// just like id, file can be identified by it's pathgetid(): string// alias to this.pathisDir: boolean// see if it has childrencontentType: stringcontent: stringsize: numbergitStatus: objectisRoot: boolean// see if this file is the root nodedepth: number// depth calc from file path, root's depth is 0parent: Filechildren: File[]siblings: File[]// all files in the same directory, including selffirstChild: File// this.children[0]lastChild: File// this.children[this.children.length - 1]prev: Filenext: File// previous/next file in same directory, return undefined if not found}
FileStore
FileStore is the manager to File related stuffs
interfaceFileStore{get(path: string): File// get file by pathisValid(file: File): boolean// test if an object is instance of File// @fixme: probably should rename this methodloadNodeData(filePropsList: FileProps[]): void// load file data, identify files by it's pathfetchProjectRoot(): void// api.fetchPath('/').then(loadNodeData)updateFile(fileProps: FileProps): void// update props of a file node, path is requiredremoveNode(file: File): void// remove the file node from state.entities}