MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / load

Method load

packages/core/src/project/project.ts:102–128  ·  view source on GitHub ↗
(schema?: ProjectSchema, autoOpen?: boolean | string)

Source from the content-addressed store, hash-verified

100 */
101 @action
102 load(schema?: ProjectSchema, autoOpen?: boolean | string) {
103 this.unload()
104
105 this.data = {
106 ...this.data,
107 ...schema,
108 }
109 this._config = schema?.config ?? this.config
110
111 // perf: 在 open 的时候才创建 document
112 // if (schema?.documents) {
113 // for (const document of schema.documents) {
114 // this.createDocument(document)
115 // }
116 // }
117
118 if (autoOpen) {
119 if (autoOpen === true) {
120 // auto open first document or open a blank page
121 const documentInstances = this.data.componentsTree.map(data => this.createDocument(data))
122 documentInstances[0].open()
123 } else {
124 // auto open should be string of fileName
125 this.open(autoOpen)
126 }
127 }
128 }
129
130 @action
131 unload() {

Callers 2

constructorMethod · 0.95
importMethod · 0.95

Calls 4

unloadMethod · 0.95
createDocumentMethod · 0.95
openMethod · 0.95
mapMethod · 0.45

Tested by

no test coverage detected