Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firstRunPromise #12824

Merged
merged 21 commits into from Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4654adb
Allow for await-able autoruns by adding firstRunPromise to computatio…
DanielDornhardt Oct 4, 2023
1a7ad0d
Merge branch 'devel' into tracker-computation-firstRunPromise
StorytellerCZ Oct 11, 2023
3a8e09a
Apply @radekmie suggestions
harryadel Oct 12, 2023
262a6dc
Merge branch 'devel' of github.com:harryadel/meteor into HEAD
harryadel Oct 12, 2023
6106a2c
Merge branch 'devel' into tracker-firstRunPromise
Grubba27 Nov 6, 2023
ff615a5
[tracker] add then and catch
harryadel Nov 19, 2023
2eb32ba
Merge branch 'tracker-firstRunPromise' of github.com:harryadel/meteor…
harryadel Nov 19, 2023
4fc44cb
Merge branch 'devel' into tracker-firstRunPromise
StorytellerCZ Nov 21, 2023
f2c98ae
[tracker] await then & catch
harryadel Nov 22, 2023
8223aef
Merge branch 'tracker-firstRunPromise' of github.com:harryadel/meteor…
harryadel Nov 22, 2023
e41c8ec
Update packages/tracker/tracker.js
harryadel Nov 28, 2023
2e32f1c
[tracker] Add a test without firstRunPromise
harryadel Nov 29, 2023
a30c131
[tracker] attach methods without the use of 'this'
harryadel Nov 29, 2023
e91c5c2
Merge branch 'devel' into tracker-firstRunPromise
harryadel Nov 29, 2023
8888925
Fixed missing firstRunPromise.
radekmie Nov 29, 2023
cc07fe5
[tracker] Remove joke because Gabriel is no fun :sob:
harryadel Dec 4, 2023
8e90991
[tracker] Use of firstRunPromise is not necessary paragraph
harryadel Dec 4, 2023
01acda0
Merge branch 'release-2.14' into tracker-firstRunPromise
StorytellerCZ Dec 4, 2023
654f366
Merge branch 'release-2.14' into tracker-firstRunPromise
StorytellerCZ Dec 4, 2023
0afa7df
Solve error in jsdoc generation
Grubba27 Dec 4, 2023
c47c3a1
Adjusting typo
Grubba27 Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/generators/changelog/versions/2.14.md
Expand Up @@ -25,15 +25,15 @@ Hacktoberfest release! 🎉
#### Migration Steps

##### Android splash screen
If you have been using `splash-screen` for Cordova, you need to update your code as Android changed their splash screen API,
the `cordova-plugin-splashscreen` is now on `cordova-android` core, so we have removed the dependency from the `splash-screen`
If you have been using `splash-screen` for Cordova, you need to update your code as Android changed their splash screen API,
the `cordova-plugin-splashscreen` is now on `cordova-android` core, so we have removed the dependency from the `splash-screen`
package. As a result we are dropping the support for dark mode splash screen on Android.

To create this now you need to create two themes on your `config.xml` file.

> Note that it's still possible to have it by adding the according themes with App.appendToConfig and App.addResourceFile - but this is not something Meteor will do automagically right now.
> Note that it's still possible to have it by adding the according themes with App.appendToConfig and App.addResourceFile - but this is not something Meteor will do automatically right now.

TODO: @matheusccastroo sample on how the new config should look and link to relevant Cordova docs
TODO: @matheusccastroo sample on how the new config should look and link to relevant Cordova docs

## Breaking Changes

Expand All @@ -55,7 +55,7 @@ TODO: @matheusccastroo sample on how the new config should look and link to rele
- Updated `semver` to v7.5.4
- Updated `@meteorjs/babel` to v7.18.4
- Cordova has been updated to v12.0.1 for Android and v7.0.1 for iOS
- `meteor create` command was re-made to be more interactive
- `meteor create` command was re-made to be more interactive

## Meteor Version Release

Expand Down Expand Up @@ -113,7 +113,7 @@ TODO: @matheusccastroo sample on how the new config should look and link to rele
- Added `appleMail` user agent to allow modern bundle on iPads

* `mongo@get-version`
- Added deprecation messages into type definitions
- Added deprecation messages into type definitions
- Fix ObjectIDs handling in oplogV2V1Converter

* `modules@get-version`
Expand Down Expand Up @@ -166,7 +166,7 @@ TODO: @matheusccastroo sample on how the new config should look and link to rele
- Remove logging request/response in google_server

* NPM `@meteorjs/babel@7.18.4`
- Updated `@meteorjs/reify` to v0.24.1
- Updated `@meteorjs/reify` to v0.24.1

* NPM `@meteorjs/babel-preset-meteor@7.10.1`
- Add Facebook in-app browser
Expand Down
12 changes: 6 additions & 6 deletions docs/source/api/tracker.md
Expand Up @@ -80,7 +80,7 @@ If the initial run of an autorun throws an exception, the computation
is automatically stopped and won't be rerun.

### Tracker.autorun and async callbacks
`Tracker.autorun` can accept an `async` callback function.
`Tracker.autorun` can accept an `async` callback function.
To preserve reactivity for the reactive variables inside the async callback function, you must use a `Tracker.withComputation` call as described below:

{% apibox "Tracker.withComputation" %}
Expand All @@ -94,7 +94,7 @@ Tracker.autorun(async function example1(computation) {

// Code after the first await looses Tracker.currentComputation: no reactivity.
reactiveVar2.get(); // This won't trigger a rerun.

// You can bring back reactivity with the Tracker.withCompuation wrapper:
let users = await Tracker.withComputation(computation, () => Meteor.users.findAsync({}).fetch());

Expand All @@ -112,7 +112,7 @@ The `react-meteor-data` package uses `Tracker.withComputation` to make the `useT
More can be seen [here](https://github.com/meteor/react-packages/tree/master/packages/react-meteor-data#maintaining-the-reactive-context)

### Using async callbacks in versions of Meteor prior to 2.10
`Tracker.autorun` can accept an `async` callback function.
`Tracker.autorun` can accept an `async` callback function.
However, the async call back function will only be dependent on reactive functions called prior to any called functions that return a promise.

Example 1 - autorun `example1()` **is not** dependent on reactive changes to the `Meteor.users` collection. Because it is dependent on nothing reactive it will run only once:
Expand Down Expand Up @@ -306,7 +306,7 @@ computation has logic specific to the first run.

`Computation.firstRunPromise` will be set to the result of the call of the autorun function after the initial computation has been completed. If the autorun function is an async function, it'll then contain its promise, thus making the completion of the execution await-able. That allows us to manually synchronize autoruns like this:

```js
```js

await Tracker.autorun(async () => {
await Meteor.userAsync();
Expand All @@ -320,9 +320,9 @@ await Tracker.autorun(async () => {

```

For a better developer experience `firstRunPromise` is automagically appended to your async `autorun` calls so you don't have to write them yourself. Meaning this also works:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automagically, 🤔 I really like this word. Probably a typo here, but I think this should be something we should strive for in Meteor.

Copy link
Contributor

@Grubba27 Grubba27 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs only two times in our code base, and it does not follow that much how we write our docs, but I agree. We could review our documentation guide line and make some adjustments to be more pleasing to read.

I like this writing in docs(Puns and funny comments) generally, but I need to maintain how it is today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a typo. I meant to use it since Meteor is all about that magic. Pffffft you guys won't get it!

For a better developer experience `firstRunPromise` is automatically appended to your async `autorun` calls so you don't have to write them yourself. Meaning this also works:

```js
```js

await Tracker.autorun(async () => {
await Meteor.userAsync();
Expand Down