JSFiddle - React, Tailwind, and code Playground
by luizz
JavaScript
function Objserve(namespace, appFunc) {
var scope = [], elent = $('[data-objserve="'+namespace+'"]');
function view(name){
var tpl = $('script#'+namespace+'/'+name);
if(tpl){
}
}
function objs(sc){
Object.observe(sc, function (changes) {
changes.forEach(function(change) {
switch (change.type){
case 'add':
objs(change.object[change.name]);
// if(~~change.name == 0 && change.name != 0)
// view(change.name, change.object[change.name]);
//if(callback.hasOwnProperty('add') && typeof callback['add'] == 'function')callback['add'].call(change.object[change.name], change.name);
break;
case 'delete':
//if(callback.hasOwnProperty('del') && typeof callback['del'] == 'function')callback['del'].call(change.object[change.name], change.name);
break;
}
localStorage.setItem(namespace, JSON.stringify(scope));
console.log(change.type, change.name, change.oldValue);
});
});
};
objs(scope);
if(localStorage.getItem(namespace)) JSON.parse(localStorage.getItem(namespace)).forEach(function(item){ if(item)scope.push(item); });
appFunc.call(scope, scope);
};
Objserve('faceboot', function (scope) {
scope.likeList = [];
var inpLike = document.getElementById('nameLike'),
btnLike = document.getElementById('addLike');
function addLike() {
if (inpLike.value != '') {
$.getJSON('https://graph.facebook.com/' + inpLike.value, function (data) {
...