-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Welcome to the ZeroDevLib wiki! Here you'll find the docs for these libraries.
npm install --save zero-dev-lib
# or
yarn add zero-dev-lib
# or
git clone https://github.com/imachug/ZeroDevLib
First, the libraries depend on the new ES6 features, like class
, etc., so if you're using Babel, compile this library as well. However, in case the target environment (i.e. browser) does support the new syntax, you can just include the file via <script>
tag.
First, you need to include ZeroFrame which connects to the wrapper (it's practically the same as the js/ZeroFrame.js
file from ZeroHello). Like this:
import {ZeroFrame} from "zero-dev-lib";
// or:
import ZeroFrame from "zero-dev-lib/ZeroFrame";
// or without Babel:
// <script src="ZeroDevLib/ZeroFrame.js"></script>
const zeroFrame = new ZeroFrame();
The first syntax is recommended in case you include a lot of libraries, the second syntax is recommended when you care about the library's size (just a few KB, though), the third syntax is used when you don't use webpack.
The second thing you need to import is ZeroPage. It's a wrapper around ZeroFrame that adds useful functions and some stuff that uses Promise's instead of callbacks. So:
import ZeroFrame from "zero-dev-lib/ZeroFrame";
const zeroFrame = new ZeroFrame();
import ZeroPage from "zero-dev-lib/ZeroPage";
const zeroPage = new ZeroPage(zeroFrame);
Now you can use it like this:
console.log(await zeroPage.getSiteInfo());
// etc.