Skip to content

Conversation

kateinoigakukun
Copy link
Member

This allows users to have more flexibility to customize. For example, this allows inserting operations before/after single job execution loop.
e.g. It's useful to enable React batch rendering per job execution loop by ReactDOM.unstable_batchedUpdates.

let original = JavaScriptEventLoop.shared.queueMicrotask
JavaScriptEventLoop.shared.queueMicrotask = (job) => {
  ReactDOM.unstable_batchedUpdates(() => {
    original(job)
  })
}

This allows users to have more flexibility to customize.
For example, this allows inserting operations before/after single job
execution loop.
e.g. It's useful to enable React batch rendering per job execution loop
by `ReactDOM.unstable_batchedUpdates`.

```swift
let original = JavaScriptEventLoop.shared.queueMicrotask
JavaScriptEventLoop.shared.queueMicrotask = (job) => {
  ReactDOM.unstable_batchedUpdates(() => {
    original(job)
  })
}
```
@kateinoigakukun kateinoigakukun requested a review from a team October 3, 2022 12:15
@github-actions
Copy link

github-actions bot commented Oct 3, 2022

Time Change: -141ms (0%)

Total Time: 18,740ms

Test name Duration Change
Serialization/JavaScript function call through Wasm import 23ms +1ms (5%) 🔍
Serialization/JavaScript function call through Wasm import with int 20ms -2ms (11%) 👏
View Unchanged
Test name Duration Change
Serialization/JavaScript function call from Swift 200ms +2ms (0%)
Serialization/Swift Int to JavaScript with assignment 448ms -7ms (1%)
Serialization/Swift Int to JavaScript with call 1,384ms -12ms (0%)
Serialization/JavaScript Number to Swift Int 480ms +3ms (0%)
Serialization/Swift String to JavaScript with assignment 508ms -4ms (0%)
Serialization/Swift String to JavaScript with call 1,493ms -10ms (0%)
Serialization/JavaScript String to Swift String 5,976ms +30ms (0%)
Object heap/Increment and decrement RC 8,191ms -140ms (1%)
View Baselines
Test name Duration
Serialization/Call JavaScript function directly 2ms
Serialization/Assign JavaScript number directly 3ms
Serialization/Call with JavaScript number directly 5ms
Serialization/Write JavaScript string directly 4ms
Serialization/Call with JavaScript string directly 4ms

@kateinoigakukun kateinoigakukun merged commit 320282f into main Oct 3, 2022
@kateinoigakukun kateinoigakukun deleted the katei/expose-hook-points branch October 3, 2022 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants