MCPcopy Create free account
hub / github.com/facebook/Rapid / startAsync

Method startAsync

modules/core/UiSystem.js:173–218  ·  view source on GitHub ↗

* startAsync * Called after all core objects have been initialized. * @return {Promise} Promise resolved when this component has completed startup

()

Source from the content-addressed store, hash-verified

171 * @return {Promise} Promise resolved when this component has completed startup
172 */
173 startAsync() {
174 if (this._startPromise) return this._startPromise;
175
176 const context = this.context;
177 const editor = context.systems.editor;
178 const map = context.systems.map;
179 const storage = context.systems.storage;
180 const urlhash = context.systems.urlhash;
181 const $container = context.container();
182
183 if (!$container.size()) {
184 return Promise.reject(new Error('No container to render to.'));
185 }
186
187 // These systems currently don't do anything in start,
188 // but if they did, we'd want them to settle first.
189 const prerequisites = Promise.all([
190 editor.startAsync(),
191 map.startAsync()
192 ]);
193
194 return this._startPromise = prerequisites
195 .then(() => {
196 this.render(); // Render one time
197 this.resize(); // Update map dimensions - this should happen after .main-content and toolbars exist.
198
199 context.enter('browse');
200
201 // What to show first?
202 const startWalkthrough = urlhash.initialHashParams.get('walkthrough') === 'true';
203 const sawPrivacyVersion = parseInt(storage.getItem('sawPrivacyVersion'), 10) || 0;
204 const sawWhatsNewVersion = parseInt(storage.getItem('sawWhatsNewVersion'), 10) || 0;
205
206 if (startWalkthrough) {
207 $container.call(uiIntro(context)); // Jump right into walkthrough..
208 } else if (editor.canRestoreBackup) {
209 $container.call(uiRestore(context)); // Offer to restore backup edits..
210 } else if (sawPrivacyVersion !== context.privacyVersion) {
211 $container.call(uiSplash(context)); // Show "Welcome to Rapid" / Privacy Policy
212 } else if (sawWhatsNewVersion !== context.whatsNewVersion) {
213 $container.call(uiWhatsNew(context)); // Show "Whats New"
214 }
215
216 this._started = true;
217 });
218 }
219
220
221 /**

Callers 13

initAsyncMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45
enabledMethod · 0.45

Calls 10

renderMethod · 0.95
resizeMethod · 0.95
uiIntroFunction · 0.90
uiRestoreFunction · 0.90
uiSplashFunction · 0.90
uiWhatsNewFunction · 0.90
getMethod · 0.80
containerMethod · 0.45
enterMethod · 0.45
getItemMethod · 0.45

Tested by

no test coverage detected