standart code styling

This commit is contained in:
Fatih Kadir Akın 2018-10-21 23:00:23 +03:00
parent c2ec610e06
commit b129212dce
2 changed files with 84 additions and 84 deletions

View File

@ -20,58 +20,58 @@ import { options } from "omi";
/*
* @see https://developers.google.com/web/updates/2015/08/using-requestidlecallback
*/
window.requestIdleCallback = window.requestIdleCallback ||
function (cb) {
return setTimeout(function () {
var start = Date.now()
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start))
}
})
}, 1)
}
window.requestIdleCallback =
window.requestIdleCallback ||
function(cb) {
return setTimeout(function() {
var start = Date.now();
cb({
didTimeout: false,
timeRemaining: function() {
return Math.max(0, 50 - (Date.now() - start));
}
});
}, 1);
};
window.cancelIdleCallback = window.cancelIdleCallback ||
function (id) {
clearTimeout(id)
}
window.cancelIdleCallback =
window.cancelIdleCallback ||
function(id) {
clearTimeout(id);
};
options.afterInstall = function(ele) {
if (ele.constructor.observe) {
oba(ele.data, ele);
}
};
options.afterInstall = function (ele) {
if (ele.constructor.observe) {
oba(ele.data, ele)
}
}
let idleId = null
const updateList = []
let idleId = null;
const updateList = [];
function oba(data, ele) {
const o = observable(data)
const o = observable(data);
autorun(() => {
JSON.stringify(o)
if (ele._isInstalled) {
updateList.push(ele)
cancelIdleCallback(idleId)
idleId = requestIdleCallback(backgroundTask)
autorun(() => {
JSON.stringify(o);
if (ele._isInstalled) {
updateList.push(ele);
cancelIdleCallback(idleId);
idleId = requestIdleCallback(backgroundTask);
}
});
}
})
ele.data = o
ele.data = o;
}
function backgroundTask(deadline) {
while (deadline.timeRemaining() > 0 && updateList.length > 0) {
updateList.shift().update()
}
while (deadline.timeRemaining() > 0 && updateList.length > 0) {
updateList.shift().update();
}
if (updateList.length > 0) {
idleId = requestIdleCallback(backgroundTask);
}
if (updateList.length > 0) {
idleId = requestIdleCallback(backgroundTask);
}
}
function observe(target) {

View File

@ -1,5 +1,5 @@
import { observable, autorun } from "mobx";
import { options } from "../../src/omi";
import { observable, autorun } from "mobx"
import { options } from "../../src/omi"
/*!
* Copyright 2015 Google Inc. All rights reserved.
@ -20,66 +20,66 @@ import { options } from "../../src/omi";
/*
* @see https://developers.google.com/web/updates/2015/08/using-requestidlecallback
*/
window.requestIdleCallback = window.requestIdleCallback ||
function (cb) {
return setTimeout(function () {
var start = Date.now()
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start))
}
})
}, 1)
}
window.requestIdleCallback =
window.requestIdleCallback ||
function(cb) {
return setTimeout(() => {
let start = Date.now()
cb({
didTimeout: false,
timeRemaining() {
return Math.max(0, 50 - (Date.now() - start))
}
})
}, 1)
}
window.cancelIdleCallback = window.cancelIdleCallback ||
function (id) {
clearTimeout(id)
}
window.cancelIdleCallback =
window.cancelIdleCallback ||
function(id) {
clearTimeout(id)
}
options.afterInstall = function (ele) {
if (ele.constructor.observe) {
oba(ele.data, ele)
}
options.afterInstall = function(ele) {
if (ele.constructor.observe) {
oba(ele.data, ele)
}
}
let idleId = null
const updateList = []
function oba(data, ele) {
const o = observable(data)
const o = observable(data)
autorun(() => {
JSON.stringify(o)
if (ele._isInstalled) {
updateList.push(ele)
cancelIdleCallback(idleId)
idleId = requestIdleCallback(backgroundTask)
autorun(() => {
JSON.stringify(o)
if (ele._isInstalled) {
updateList.push(ele)
cancelIdleCallback(idleId)
idleId = requestIdleCallback(backgroundTask)
}
})
}
})
ele.data = o
ele.data = o
}
function backgroundTask(deadline) {
while (deadline.timeRemaining() > 0 && updateList.length > 0) {
updateList.shift().update()
}
while (deadline.timeRemaining() > 0 && updateList.length > 0) {
updateList.shift().update()
}
if (updateList.length > 0) {
idleId = requestIdleCallback(backgroundTask);
}
if (updateList.length > 0) {
idleId = requestIdleCallback(backgroundTask)
}
}
function observe(target) {
target.observe = true;
target.observe = true
}
export { observe };
export { observe }
export default {
observe
};
}