Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
aaa9b6c
chore: added async to collections
Grubba27 Aug 31, 2022
58c914c
chore(step02): added async methods
Grubba27 Aug 31, 2022
3d82d57
chore(step03):updated ui
Grubba27 Aug 31, 2022
9bca17a
chore(step03):updated server
Grubba27 Aug 31, 2022
64a4b37
chore(step04-client): added async methods
Grubba27 Aug 31, 2022
531e45a
chore(step04-server): added async methods
Grubba27 Aug 31, 2022
2a781c2
chore(step05-client): added async methods
Grubba27 Aug 31, 2022
f2213d6
chore(step05-server): added async methods
Grubba27 Aug 31, 2022
47d8a1d
chore(step06-client):added async methods
Grubba27 Aug 31, 2022
af72bac
chore(step06-server):added async methods
Grubba27 Aug 31, 2022
598f263
chore(step07): updated app.jsx
Grubba27 Sep 1, 2022
f2b31a3
chore(step07): updated taskform.jsx
Grubba27 Sep 1, 2022
36dea7f
chore(step07): updated server
Grubba27 Sep 1, 2022
65cbd1f
chore(step08): updated app.jsx
Grubba27 Sep 1, 2022
eba7ee2
chore(step08): updated TaskForm.jsx
Grubba27 Sep 1, 2022
1a241fc
chore(step08): updated server/main.js
Grubba27 Sep 1, 2022
5e3fa37
chore(step08): update on app.jsx
Grubba27 Sep 1, 2022
2f64dd1
chore(step09): update taskMethods.js
Grubba27 Sep 1, 2022
b4c8055
chore(step09): update app.jsx
Grubba27 Sep 1, 2022
61d6b0e
chore(step09): update taskForm.jsx
Grubba27 Sep 1, 2022
bdbb434
chore(step09): update server.js
Grubba27 Sep 1, 2022
461bd87
chore(step10): update taskMethods.js
Grubba27 Sep 1, 2022
17710c7
chore(step10): update app.jsx
Grubba27 Sep 1, 2022
e59e3f4
chore(step10): update taskForm.jsx
Grubba27 Sep 1, 2022
2ebe384
chore(step10): update main.js
Grubba27 Sep 1, 2022
137a7e0
chore(step11): updated taskMethods.js
Grubba27 Sep 1, 2022
dad0c32
chore(step11): updated loginForm.jsx
Grubba27 Sep 1, 2022
5ebe029
chore(step11): updated taskForm.jsx
Grubba27 Sep 1, 2022
329d7d9
fix(step11): updated missing async keywords
Grubba27 Sep 1, 2022
43b8302
fix(step11): updated main.js
Grubba27 Sep 1, 2022
98b47b7
chore(step12): updated taskMethod.js
Grubba27 Sep 1, 2022
db0769a
chore(step12): updated taskMethod.tests.js
Grubba27 Sep 1, 2022
2e67453
chore(step12): updated app.jsx
Grubba27 Sep 1, 2022
d76c193
chore(step12): updated loginForm.jsx
Grubba27 Sep 1, 2022
001ae54
chore(step12): updated taskForm.jsx
Grubba27 Sep 1, 2022
fa548f7
chore(step13): updated taskForm.jsx
Grubba27 Sep 1, 2022
39c7725
chore(step13): updated LoginForm.jsx
Grubba27 Sep 1, 2022
9071ddf
chore(step13): updated app.jsx
Grubba27 Sep 1, 2022
708dab8
chore(step13): updated tasksMethods.tests.js
Grubba27 Sep 1, 2022
cfa2388
chore(step13): updated tasksMethods.js
Grubba27 Sep 1, 2022
0ee4a42
fix(step02): added missing async await
Grubba27 Sep 1, 2022
c5bae23
fix(step02): added async to main.js
Grubba27 Sep 1, 2022
e2ae6cb
fix(step04): added async to app.jsx
Grubba27 Sep 1, 2022
8f8235b
fix(step05): added async to app.jsx
Grubba27 Sep 1, 2022
2ff49c0
fix(step06): added async to app.jsx
Grubba27 Sep 1, 2022
def3f0d
fix(step07): added async to app.jsx
Grubba27 Sep 1, 2022
c8340ea
fix(step08): added async to app.jsx
Grubba27 Sep 1, 2022
b17e31d
fix(step03): converted to async in TaskForm.jsx
Grubba27 Sep 1, 2022
3721394
fix(step04): converted to async in TaskForm.jsx
Grubba27 Sep 1, 2022
a5b1e22
fix(step05): converted to async in TaskForm.jsx
Grubba27 Sep 1, 2022
aedb561
fix(step06): converted to async in TaskForm.jsx
Grubba27 Sep 1, 2022
4261c9d
docs(step02): updated docs to mongo api
Grubba27 Sep 1, 2022
b719930
fix(step07): missing params in main.js
Grubba27 Sep 1, 2022
d627773
docs(step03): updated docs to async mongo api
Grubba27 Sep 1, 2022
8b2ad9e
docs(step04): updated docs to async mongo api
Grubba27 Sep 1, 2022
5e07dee
docs(step06): updated docs to async mongo api
Grubba27 Sep 1, 2022
a59128e
docs(step07): updated docs to async mongo api
Grubba27 Sep 1, 2022
6cd15f7
docs(step09): updated docs to async mongo api
Grubba27 Sep 1, 2022
2f608a9
docs(step10): updated docs to async mongo api
Grubba27 Sep 1, 2022
2bb7f9f
docs(step12): updated docs to async mongo api
Grubba27 Sep 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/simple-todos/step01/server/main.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { Meteor } from 'meteor/meteor';
import { LinksCollection } from '/imports/api/links';

function insertLink({ title, url }) {
LinksCollection.insert({ title, url, createdAt: new Date() });
async function insertLink({ title, url }) {
await LinksCollection.insertAsync({ title, url, createdAt: new Date() });
}

Meteor.startup(() => {
Meteor.startup(async () => {
// If the Links collection is empty, add some data.
if (LinksCollection.find().count() === 0) {
insertLink({
if (await LinksCollection.find().countAsync() === 0) {
await insertLink({
title: 'Do the Tutorial',
url: 'https://www.meteor.com/tutorials/react/creating-an-app',
});

insertLink({
await insertLink({
title: 'Follow the Guide',
url: 'http://guide.meteor.com',
});

insertLink({
await insertLink({
title: 'Read the Docs',
url: 'https://docs.meteor.com',
});

insertLink({
await insertLink({
title: 'Discussions',
url: 'https://forums.meteor.com',
});
Expand Down
2 changes: 1 addition & 1 deletion src/simple-todos/step02/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TasksCollection } from '/imports/api/TasksCollection';
import { Task } from './Task';

export const App = () => {
const tasks = useTracker(() => TasksCollection.find({}).fetch());
const tasks = useTracker(async () => await TasksCollection.find({}).fetchAsync());

return (
<div>
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step02/server/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { TasksCollection } from '/imports/api/TasksCollection';

const insertTask = taskText => TasksCollection.insert({ text: taskText });
const insertTask =
async (taskText) => await TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (await TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step03/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Task } from './Task';
import { TaskForm } from './TaskForm';

export const App = () => {
const tasks = useTracker(() =>
TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch()
const tasks = useTracker(async () =>
await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync()
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step03/imports/ui/TaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection';
export const TaskForm = () => {
const [text, setText] = useState('');

const handleSubmit = e => {
const handleSubmit = async (e) => {
e.preventDefault();

if (!text) return;

TasksCollection.insert({
await TasksCollection.insertAsync({
text: text.trim(),
createdAt: new Date(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step03/server/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { TasksCollection } from '/imports/api/TasksCollection';

const insertTask = taskText => TasksCollection.insert({ text: taskText });
const insertTask =
async (taskText) => TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (await TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
22 changes: 12 additions & 10 deletions src/simple-todos/step04/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import { TasksCollection } from '/imports/api/TasksCollection';
import { Task } from './Task';
import { TaskForm } from './TaskForm';

const toggleChecked = ({ _id, isChecked }) => {
TasksCollection.update(_id, {
$set: {
isChecked: !isChecked,
},
});
};
const toggleChecked =
async ({ _id, isChecked }) => {
await TasksCollection.updateAsync(_id, {
$set: {
isChecked: !isChecked,
},
});
};

const deleteTask = ({ _id }) => TasksCollection.remove(_id);
const deleteTask =
async ({ _id }) => await TasksCollection.removeAsync(_id);

export const App = () => {
const tasks = useTracker(() =>
TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch()
const tasks = useTracker(async () =>
await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync()
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step04/imports/ui/TaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection';
export const TaskForm = () => {
const [text, setText] = useState('');

const handleSubmit = e => {
const handleSubmit = async (e) => {
e.preventDefault();

if (!text) return;

TasksCollection.insert({
await TasksCollection.insertAsync({
text: text.trim(),
createdAt: new Date(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step04/server/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { TasksCollection } from '/imports/api/TasksCollection';

const insertTask = taskText => TasksCollection.insert({ text: taskText });
const insertTask =
async (taskText) => TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (await TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
23 changes: 13 additions & 10 deletions src/simple-todos/step05/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import { TasksCollection } from '/imports/api/TasksCollection';
import { Task } from './Task';
import { TaskForm } from './TaskForm';

const toggleChecked = ({ _id, isChecked }) => {
TasksCollection.update(_id, {
$set: {
isChecked: !isChecked,
},
});
};
const toggleChecked =
async ({ _id, isChecked }) => {
await TasksCollection.updateAsync(_id, {
$set: {
isChecked: !isChecked,
},
});
};

const deleteTask = ({ _id }) => TasksCollection.remove(_id);
const deleteTask =
async ({ _id }) => await TasksCollection.removeAsync(_id);

export const App = () => {
const tasks = useTracker(() =>
TasksCollection.find({}, { sort: { createdAt: -1 } }).fetch()
const tasks = useTracker(async () =>
await TasksCollection.find({}, { sort: { createdAt: -1 } }).fetchAsync()
Comment on lines +20 to +21
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to stop this pr because useTracker could not handle async states at the time.

Now it can. We were planing on coming back on this one following the same style as the vue3 guide that was launched

);


return (
<div className="app">
<header>
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step05/imports/ui/TaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection';
export const TaskForm = () => {
const [text, setText] = useState('');

const handleSubmit = e => {
const handleSubmit = async (e) => {
e.preventDefault();

if (!text) return;

TasksCollection.insert({
await TasksCollection.insertAsync({
text: text.trim(),
createdAt: new Date(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step05/server/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { TasksCollection } from '/imports/api/TasksCollection';

const insertTask = taskText => TasksCollection.insert({ text: taskText });
const insertTask =
async (taskText) => TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (await TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
28 changes: 15 additions & 13 deletions src/simple-todos/step06/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ import { TasksCollection } from '/imports/api/TasksCollection';
import { Task } from './Task';
import { TaskForm } from './TaskForm';

const toggleChecked = ({ _id, isChecked }) => {
TasksCollection.update(_id, {
$set: {
isChecked: !isChecked,
},
});
};
const toggleChecked =
async ({ _id, isChecked }) => {
await TasksCollection.updateAsync(_id, {
$set: {
isChecked: !isChecked,
},
});
};

const deleteTask = ({ _id }) => TasksCollection.remove(_id);
const deleteTask =
async ({ _id }) => await TasksCollection.removeAsync(_id);

export const App = () => {
const [hideCompleted, setHideCompleted] = useState(false);

const hideCompletedFilter = { isChecked: { $ne: true } };

const tasks = useTracker(() =>
TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, {
const tasks = useTracker(async () =>
await TasksCollection.find(hideCompleted ? hideCompletedFilter : {}, {
sort: { createdAt: -1 },
}).fetch()
}).fetchAsync()
);

const pendingTasksCount = useTracker(() =>
TasksCollection.find(hideCompletedFilter).count()
const pendingTasksCount = useTracker(async () =>
await TasksCollection.find(hideCompletedFilter).countAsync()
);

const pendingTasksTitle = `${
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step06/imports/ui/TaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection';
export const TaskForm = () => {
const [text, setText] = useState('');

const handleSubmit = e => {
const handleSubmit = async (e) => {
e.preventDefault();

if (!text) return;

TasksCollection.insert({
await TasksCollection.insertAsync({
text: text.trim(),
createdAt: new Date(),
});
Expand Down
7 changes: 4 additions & 3 deletions src/simple-todos/step06/server/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { TasksCollection } from '/imports/api/TasksCollection';

const insertTask = taskText => TasksCollection.insert({ text: taskText });
const insertTask =
async (taskText) => TasksCollection.insertAsync({ text: taskText });

Meteor.startup(() => {
if (TasksCollection.find().count() === 0) {
Meteor.startup(async () => {
if (await TasksCollection.find().countAsync() === 0) {
[
'First Task',
'Second Task',
Expand Down
30 changes: 16 additions & 14 deletions src/simple-todos/step07/imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { Task } from './Task';
import { TaskForm } from './TaskForm';
import { LoginForm } from './LoginForm';

const toggleChecked = ({ _id, isChecked }) => {
TasksCollection.update(_id, {
$set: {
isChecked: !isChecked,
},
});
};

const deleteTask = ({ _id }) => TasksCollection.remove(_id);
const toggleChecked =
async ({ _id, isChecked }) => {
await TasksCollection.updateAsync(_id, {
$set: {
isChecked: !isChecked,
},
});
};

const deleteTask =
async ({ _id }) => await TasksCollection.removeAsync(_id);

export const App = () => {
const user = useTracker(() => Meteor.user());
Expand All @@ -27,25 +29,25 @@ export const App = () => {

const pendingOnlyFilter = { ...hideCompletedFilter, ...userFilter };

const tasks = useTracker(() => {
const tasks = useTracker(async () => {
if (!user) {
return [];
}

return TasksCollection.find(
return await TasksCollection.find(
hideCompleted ? pendingOnlyFilter : userFilter,
{
sort: { createdAt: -1 },
}
).fetch();
).fetchAsync();
});

const pendingTasksCount = useTracker(() => {
const pendingTasksCount = useTracker(async () => {
if (!user) {
return 0;
}

return TasksCollection.find(pendingOnlyFilter).count();
return await TasksCollection.find(pendingOnlyFilter).countAsync();
});

const pendingTasksTitle = `${
Expand Down
4 changes: 2 additions & 2 deletions src/simple-todos/step07/imports/ui/TaskForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { TasksCollection } from '/imports/api/TasksCollection';
export const TaskForm = ({user}) => {
const [text, setText] = useState('');

const handleSubmit = e => {
const handleSubmit = async (e) => {
e.preventDefault();

if (!text) return;

TasksCollection.insert({
await TasksCollection.insertAsync({
text: text.trim(),
createdAt: new Date(),
userId: user._id
Expand Down
Loading