Skip to content

⚡ Release v2.0.1 #624

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

Merged
merged 6 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
93 changes: 93 additions & 0 deletions 2.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Upgrading Parse SDK to version 2.0.0

With Parse SDK 2.0.0, gone are the backbone style callbacks and Parse.Promises.

Instead, the Parse SDK 2.0.0 uses native promises in the browser, node and react native that allows for a more standard API.

Migrating to native Promises should be straightforward, we'll recap the different changes:

## `.done()` and `.fail()` continuations

With native promises, `.done` and `.fail` don't exist and are replaces by `.then` and `.catch`

```js
// before
const query = new Parse.Query();
query.find()
.done((results) => {

})
.fail((error) => {

});

// after
query.find()
.then((results) => {

})
.catch((error) => {

});
```

## `.always()` is replaced by `.finally()`

```js
// before
const query = new Parse.Query();
query.find()
.always((result) => {

});

// after
query.find()
.finally((result) => {

});
```

## `new Parse.Promise()`

With native promises, the constructor is different, you will need to update to the native constructor which requires moving the code around.

```js
// before
const promise = new Promise();
doSomethingAsync((error, success) => {
if (error) { promise.reject(error); }
else { promise.resolve(success); }
});
return promise;

// after
return new Promise((resolve, reject) => {
doSomethingAsync((error, success) => {
if (error) { reject(error); }
else { resolve(success); }
});
});
```

## Static methods

- `Parse.Promise.as` is replaced by `Promise.resolve`
- `Parse.Promise.error` is replaced by `Promise.reject`
- `Parse.Promise.when` is replaced by `Promise.all`

:warning: `Promise.all` only takes an array or an iterable promises.

```js
// before
Parse.Promise.when(promise1, promise2, promise3)
.then((result1, result2, result3) => {

});

// after
Promise.all([promise1, promise2, promise3])
.then(([result1, result2, result3]) => {

});
```
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Parse-SDK-JS

## 2.0.1

- Ensure we only read the job status id header if present.

## 2.0.0

- Parse.Promise has been replaced by native Promises
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ var AsyncStorage = require('react-native').AsyncStorage;
Parse.setAsyncStorage(AsyncStorage);
```

## Upgrading to Parse SDK 2.0.0

With Parse SDK 2.0.0, gone are the backbone style callbacks and Parse.Promises.

We have curated a [migration guide](2.0.0.md) that should help you migrate your code.

## License

```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse",
"version": "2.0.0",
"version": "2.0.1",
"description": "The Parse JavaScript SDK",
"homepage": "https://www.parse.com",
"keywords": [
Expand Down