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
@@ -198,7 +268,25 @@ export function createRoot(rootConfig?: RootConfig): Root {
198
268
* It does not wait for it to be flushed in the UI thread or for it to be
199
269
* processed by JS.
200
270
*
201
-
* For a higher level API, use `dispatchNativeEvent`.
271
+
* When you simply need to dispatch a native event and observe its effects, use `dispatchNativeEvent`.
272
+
*
273
+
* @param node - The node to which the event will be dispatched. You must make sure the event is appropriate for the provided node. For example, if sending a scroll event, you must make sure the node is of type <ScrollView />.
274
+
* @param type - The type of the event. e.g 'focus', 'blur', 'change', 'scroll', etc.
275
+
* @param payload - The data associated with the event. What is delivered as `event.nativeEvent` on a component.
276
+
* @param options - Object describing what priority the event is and whether it gets coalesced. For event priority, see `NativeEventCategory`.
277
+
*
278
+
* @example
279
+
* ```
280
+
* Fantom.runOnUIThread(() => {
281
+
* Fantom.enqueueNativeEvent(element, 'focus');
282
+
* });
283
+
*
284
+
* // The effects of `focus` event are *not* yet observable.
285
+
*
286
+
* Fantom.runWorkLoop();
287
+
*
288
+
* // The effects of `focus` event are observable.
289
+
* ```
202
290
*/
203
291
exportfunctionenqueueNativeEvent(
204
292
node: ReactNativeElement,
@@ -216,6 +304,21 @@ export function enqueueNativeEvent(
216
304
);
217
305
}
218
306
307
+
/**
308
+
* Dispatches a native event and makes sure its effects are observable after calling this method.
309
+
*
310
+
* @param node - The node to which the event will be dispatched. You must make sure the event is appropriate for the provided node. For example, if sending a scroll event, you must make sure the node is of type <ScrollView />.
311
+
* @param type - The type of the event. e.g 'focus', 'blur', 'change', 'scroll', etc.
312
+
* @param payload - The data associated with the event. What is delivered as `event.nativeEvent` on a component.
313
+
* @param options - Object describing what priority the event is and whether it gets coalesced. For event priority, see `NativeEventCategory`.
314
+
*
315
+
* @example
316
+
* ```
317
+
* Fantom.dispatchNativeEvent(element, 'focus');
318
+
*
319
+
* // The effects of `focus` are immediately observable.
320
+
* ```
321
+
*/
219
322
exportfunctiondispatchNativeEvent(
220
323
node: ReactNativeElement,
221
324
type: string,
@@ -235,6 +338,47 @@ export type ScrollEventOptions = {
235
338
zoomScale?: number,
236
339
};
237
340
341
+
/**
342
+
* Enqueues an event to scroll a <ScrollView /> node to the given coordinates.
343
+
* It does not wait for it to be flushed in the UI thread or for it to be
344
+
* processed by JS.
345
+
*
346
+
* When you need to simply scroll a <ScrollView /> and observe effects immediately, use `Fantom.scrollTo`.
347
+
*
348
+
* @params node - A node to be scrolled. Must be of type <ScrollView />.
349
+
* @params options - Object describing the scroll position and zoom level. See `ScrollEventOptions` for more details.
350
+
*
351
+
* @example
352
+
* ```
353
+
* const root = Fantom.createRoot();
354
+
* let maybeScrollViewNode;
355
+
*
356
+
* Fantom.runTask(() => {
357
+
* root.render(
358
+
* <ScrollView
359
+
* ref={node => {
360
+
* maybeScrollViewNode = node;
361
+
* }} />
362
+
* <ScrollViewContent />
363
+
* </ScrollView>,
364
+
* );
365
+
* });
366
+
*
367
+
* const element = ensureInstance(maybeScrollViewNode, ReactNativeElement);
368
+
*
369
+
* Fantom.runOnUIThread(() => {
370
+
* Fantom.enqueueScrollEvent(element, {
371
+
* x: 20,
372
+
* y: 10,
373
+
* });
374
+
*
375
+
* // The changes from scroll event are *not* yet observable.
376
+
*
377
+
* Fantom.runWorkLoop();
378
+
*
379
+
* // The changes from scroll event are observable.
380
+
* ```
381
+
*/
238
382
exportfunctionenqueueScrollEvent(
239
383
node: ReactNativeElement,
240
384
options: ScrollEventOptions,
@@ -248,6 +392,9 @@ export function enqueueScrollEvent(
248
392
* The call is immediately observable unlike `Fantom.enqueueScrollEvent` where the
249
393
* event is queued and not processed.
250
394
*
395
+
* @params node - A node to be scrolled. Must be of type <ScrollView />.
396
+
* @params options - Object describing the scroll position and zoom level. See `ScrollEventOptions` for more details.
397
+
*
251
398
* @example
252
399
* ```
253
400
* const root = Fantom.createRoot();
@@ -282,6 +429,30 @@ export function scrollTo(
282
429
runWorkLoop();
283
430
}
284
431
432
+
/**
433
+
* Enqueues modal size update for a given node.
434
+
* It does not wait for it to be processed and effects are not observable after calling this method.
435
+
* Can only be called on <Modal />.
436
+
*
437
+
* @params node - A node to have its size updated. Must be of type <Modal />.
438
+
* @params size - New size for the node. This would typically be screen size.
439
+
*
440
+
* @example
441
+
* ```
442
+
* Fantom.runOnUIThread(() => {
443
+
* Fantom.enqueueModalSizeUpdate(modalElement, {
444
+
* width: 100,
445
+
* height: 100,
446
+
* });
447
+
* });
448
+
*
449
+
* // The effects of `enqueueModalSizeUpdate` are *not* yet observable.
450
+
*
451
+
* Fantom.runWorkLoop();
452
+
*
453
+
* // The effects of `enqueueModalSizeUpdate` are yet observable.
454
+
* ```
455
+
*/
285
456
exportfunctionenqueueModalSizeUpdate(
286
457
node: ReactNativeElement,
287
458
size: {width: number,height: number},
@@ -372,6 +543,17 @@ if (typeof global.EventTarget === 'undefined') {
372
543
);
373
544
}
374
545
546
+
/**
547
+
* Saves a heap snapshot after forcing garbage collection.
548
+
*
549
+
* The heapsnapshot is saved to the filename supplied as an argument.
550
+
* If a relative path is supplied, it will be saved relative to where you are invoking the tests.
551
+
*
552
+
* The supplied filename should end in .heapsnapshot, and it can be opened
553
+
* using the "Memory" pane in Chrome DevTools.
554
+
*
555
+
* @param filepath - File where JS memory heap will be saved.
0 commit comments