aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-09-17 19:52:25 +0800
committerFabio Berger <me@fabioberger.com>2018-09-17 19:52:25 +0800
commit6b9f0af82840f53abc1f9e46b6d005d13be0795a (patch)
tree0686c30969b4c357628b36ba0a7f63885f62c018
parentbfabf765e30d396c884220a786a6f748fd540e2f (diff)
downloaddexon-sol-tools-6b9f0af82840f53abc1f9e46b6d005d13be0795a.tar.gz
dexon-sol-tools-6b9f0af82840f53abc1f9e46b6d005d13be0795a.tar.zst
dexon-sol-tools-6b9f0af82840f53abc1f9e46b6d005d13be0795a.zip
Add 0x.js 2.0.0 async and installation sections
-rw-r--r--packages/website/md/docs/0xjs/2.0.0/async.md26
-rw-r--r--packages/website/md/docs/0xjs/2.0.0/installation.md38
2 files changed, 64 insertions, 0 deletions
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
+<script type="text/javascript" src="0x.js"></script>
+```
+
+### Wiki
+
+Check out our [wiki](https://0xproject.com/wiki) for articles on how to get 0x.js setup with TestRPC, Infura and more!