loops-tools v0.0.21
Loops Tools
Includes every thing the need to be included while developing loops web pages (web apps) author lishuo@mozat.com
Quick Start
in your VUE app:
...
import LoopsTools from 'loops-tools';
...
Vue.use(LoopsTools);
// or
Vue.use(LoopsTools, { env: 'production' }); // for production env
// production env will use production API URL and all production settings.
install params:
- beginToForeground (when web page back to visible)
- beginToBackground (when web page hide to back)
- onDestroy (when web view begin to destroy)
wanna call an API?
import { api, request } from 'loops-tools';
// no uid & token param needed. will auto get params from **url param**
// **UNLESS** you manually pass it into the **params**. that will override the url params.
request(api.topupReward, ${params})
.then(res => {
...
// do every thing with your result.
})
// or
api.topupReward.request(${params})
.then(res =>{
...
// same here or different code styles.
})
other tools:
import { inapp, points } from 'loops-tools';
// wanna inject a DI point?
inapp.di(points(${pointid}));
// wanna open a app page?
inapp.openAppPage(${pageName}});
// wanna get other url params?
import { utils } from 'loops-tools';
const pageType = utils.getUrlParams('pageType');
// multiple
const { param1, param2 } = utils.getUrlParams('param1', param2);
pretty simple and all you need is focus on the page logic.
of course. if there are new APIs or features required. need to manually update the lib. but that also make this lib extensible and flexible.
Overview
Module structure:
utils, // include all utils. lke get url param and find, filter functions.
request, // method to request APIs. alias for utils.request. because frequently used
inapp, // in APP features. like DI, open APP page etc..
api, // APIS.
points, // di points
VERSION, // tools version. can see the release log to decide if this tools include requeired features.
Utils Methods
utils.getUrlParams(paramNames)
Argument
paramName (array of string, string) : the param names
Returns
string or object
Example
const something = utils.getUrlParams('something');
const { param1, param2 } = utils.getUrlParams(['param1', 'param2']);
utils.getMobileOperatingSystem()
Argument
Returns
enum'Windows Phone', 'Android', 'iOS', 'unknown'
Example
utils.getChromeVersion()
Argument
Returns
number of chrome version
Example
utils._
include Lodash core (~4kb)
.assignIn, .before, .bind, .chain, .clone, .compact, .concat, .create, .defaults, .defer, .delay, .each, .escape, .every, .filter, .find, .flatten, .flattenDeep, .forEach, .has, .head, .identity, .indexOf, .isArguments, .isArray, .isBoolean, .isDate, .isEmpty, .isEqual, .isFinite, .isFunction, .isNaN, .isNull, .isNumber, .isObject, .isRegExp, .isString, .isUndefined, .iteratee, .keys, .last, .map, .matches, .max, .min, .mixin, .negate, .noConflict, .noop, .once, .pick, .reduce, .result, .size, .slice, .some, .sortBy, .tap, .thru, .toArray, .uniqueId, #value, & _.values
for more information: https://github.com/lodash/lodash/wiki/Build-Differences
Inapp methods
https://mozat.com/confluence/pages/viewpage.action?title=Custom+URL&spaceKey=LC
inapp.di(diPoint: DIPoint, params: Object = {})
Argument
dipoint: dipoint params: params.
Returns
-
Example
inapp.di(points(14012));
inapp.toast(text: String)
Argument
text: toast string.
Returns
-
Example
inapp.toast('toast test');
openAppPage(pageName: String)
Argument
pageName: page name.
page name:
mydiamond,home,mylevel,leaderboard,mytitle,topup,myprofile
unlockType
(set only when pageName == "mytitle")
// -1: default
// 0: ‘all’
// 1: ‘broadcaster’
// 2: ‘looper ’
Returns
-
Example
inapp.openAppPage('mytitle');
openVideo(sid: String, cid: String)
Argument
sid: session id cid: channel id
Returns
-
Example
inapp.openVideo('v9495', '110012');
openURL(url: String, title: String)
Argument
url: url title : title
Returns
-
Example
inapp.openURL('http://www.google.com', 'Google');
API
see code for more informations
Points
see code for more informations