From 6b9f0af82840f53abc1f9e46b6d005d13be0795a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 17 Sep 2018 12:52:25 +0100 Subject: Add 0x.js 2.0.0 async and installation sections --- packages/website/md/docs/0xjs/2.0.0/async.md | 26 +++++++++++++++ .../website/md/docs/0xjs/2.0.0/installation.md | 38 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 packages/website/md/docs/0xjs/2.0.0/async.md create mode 100644 packages/website/md/docs/0xjs/2.0.0/installation.md diff --git a/packages/website/md/docs/0xjs/2.0.0/async.md b/packages/website/md/docs/0xjs/2.0.0/async.md new file mode 100644 index 000000000..c84eebf94 --- /dev/null +++ b/packages/website/md/docs/0xjs/2.0.0/async.md @@ -0,0 +1,26 @@ +0x.js is a promise-based library. This means that whenever an asynchronous call is required, the library method will return a native Javascript promise. You can therefore choose between using `promise` or `async/await` syntax when calling our async methods. + +_Async/await syntax (recommended):_ + +```javascript +try { + var availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); +} catch (error) { + console.log('Caught error: ', error); +} +``` + +_Promise syntax:_ + +```javascript +web3Wrapper + .getAvailableAddressesAsync() + .then(function(availableAddresses) { + console.log(availableAddresses); + }) + .catch(function(error) { + console.log('Caught error: ', error); + }); +``` + +As is the convention with promise-based libraries, if an error occurs, it is thrown. It is the callers responsibility to catch thrown errors and to handle them appropriately. diff --git a/packages/website/md/docs/0xjs/2.0.0/installation.md b/packages/website/md/docs/0xjs/2.0.0/installation.md new file mode 100644 index 000000000..aaac263d0 --- /dev/null +++ b/packages/website/md/docs/0xjs/2.0.0/installation.md @@ -0,0 +1,38 @@ +0x.js ships as both a [UMD](https://github.com/umdjs/umd) module and a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) package. + +#### CommonJS _(recommended)_: + +**Install** + +```bash +npm install 0x.js --save +``` + +**Import** + +```javascript +import { + assetDataUtils, + BigNumber, + ContractWrappers, + generatePseudoRandomSalt, + orderHashUtils, + signatureUtils, +} from '0x.js'; +``` + +#### UMD: + +**Install** + +Download the UMD module from our [releases page](https://github.com/0xProject/0x-monorepo/releases) and add it to your project. + +**Import** + +```html + +``` + +### Wiki + +Check out our [wiki](https://0xproject.com/wiki) for articles on how to get 0x.js setup with TestRPC, Infura and more! -- cgit v1.2.3