Skip to content

Commit 2e69f39

Browse files
authored
⚡ Release v2.0.1 (#624)
* ⚡ Release v2.0.1 * Adds documentation for async functions * Adds documentation about 2.0.0 * Adds upgrade guide * Reverts CloudCode docs
1 parent 64aacec commit 2e69f39

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

2.0.0.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Upgrading Parse SDK to version 2.0.0
2+
3+
With Parse SDK 2.0.0, gone are the backbone style callbacks and Parse.Promises.
4+
5+
Instead, the Parse SDK 2.0.0 uses native promises in the browser, node and react native that allows for a more standard API.
6+
7+
Migrating to native Promises should be straightforward, we'll recap the different changes:
8+
9+
## `.done()` and `.fail()` continuations
10+
11+
With native promises, `.done` and `.fail` don't exist and are replaces by `.then` and `.catch`
12+
13+
```js
14+
// before
15+
const query = new Parse.Query();
16+
query.find()
17+
.done((results) => {
18+
19+
})
20+
.fail((error) => {
21+
22+
});
23+
24+
// after
25+
query.find()
26+
.then((results) => {
27+
28+
})
29+
.catch((error) => {
30+
31+
});
32+
```
33+
34+
## `.always()` is replaced by `.finally()`
35+
36+
```js
37+
// before
38+
const query = new Parse.Query();
39+
query.find()
40+
.always((result) => {
41+
42+
});
43+
44+
// after
45+
query.find()
46+
.finally((result) => {
47+
48+
});
49+
```
50+
51+
## `new Parse.Promise()`
52+
53+
With native promises, the constructor is different, you will need to update to the native constructor which requires moving the code around.
54+
55+
```js
56+
// before
57+
const promise = new Promise();
58+
doSomethingAsync((error, success) => {
59+
if (error) { promise.reject(error); }
60+
else { promise.resolve(success); }
61+
});
62+
return promise;
63+
64+
// after
65+
return new Promise((resolve, reject) => {
66+
doSomethingAsync((error, success) => {
67+
if (error) { reject(error); }
68+
else { resolve(success); }
69+
});
70+
});
71+
```
72+
73+
## Static methods
74+
75+
- `Parse.Promise.as` is replaced by `Promise.resolve`
76+
- `Parse.Promise.error` is replaced by `Promise.reject`
77+
- `Parse.Promise.when` is replaced by `Promise.all`
78+
79+
:warning: `Promise.all` only takes an array or an iterable promises.
80+
81+
```js
82+
// before
83+
Parse.Promise.when(promise1, promise2, promise3)
84+
.then((result1, result2, result3) => {
85+
86+
});
87+
88+
// after
89+
Promise.all([promise1, promise2, promise3])
90+
.then(([result1, result2, result3]) => {
91+
92+
});
93+
```

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Parse-SDK-JS
22

3+
## 2.0.1
4+
5+
- Ensure we only read the job status id header if present.
6+
37
## 2.0.0
48

59
- Parse.Promise has been replaced by native Promises

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ var AsyncStorage = require('react-native').AsyncStorage;
4545
Parse.setAsyncStorage(AsyncStorage);
4646
```
4747

48+
## Upgrading to Parse SDK 2.0.0
49+
50+
With Parse SDK 2.0.0, gone are the backbone style callbacks and Parse.Promises.
51+
52+
We have curated a [migration guide](2.0.0.md) that should help you migrate your code.
53+
4854
## License
4955

5056
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "The Parse JavaScript SDK",
55
"homepage": "https://www.parse.com",
66
"keywords": [

0 commit comments

Comments
 (0)