Skip to content

Instantly share code, notes, and snippets.

View lili21's full-sized avatar
🎯
Focusing

li.li lili21

🎯
Focusing
View GitHub Profile
@lili21
lili21 / deferred-overview.md
Created February 25, 2023 16:37 — forked from jacob-ebey/deferred-overview.md
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@lili21
lili21 / index.jsx
Created September 2, 2020 12:18
test
function Test() {
const [postionList, setPostionList] = setState([
{
id: 1,
title: 'a',
selected: false
},
{
id: 2,
title: 'b',
@lili21
lili21 / domtokenlist_feature_detection.js
Created February 5, 2018 09:08 — forked from igrigorik/domtokenlist_feature_detection.js
DOMTokenList supports() example for Preload
var DOMTokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@lili21
lili21 / supportsES6.js
Created December 13, 2017 06:19 — forked from bendc/supportsES6.js
Test if ES6 is ~fully supported
var supportsES6 = function() {
try {
new Function("(a = 0) => a");
return true;
}
catch (err) {
return false;
}
}();
@lili21
lili21 / LICENSE
Created August 29, 2017 04:00 — forked from rkirsling/LICENSE
Directed Graph Editor
Copyright (c) 2013-2015 Ross Kirsling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@lili21
lili21 / curry.js
Created August 19, 2017 04:17
infinite curry
function curry(fn) {
var _args = []
return function _fn (...args) {
_args = [..._args, ...args]
if (args.length) {
return _fn
} else {
const r = _args.reduce(fn)
_args = []
return r
@lili21
lili21 / co.js
Last active August 14, 2017 07:36
generator, promise.
function co (_g) {
const ge = _g()
next(ge)
}
function next(ge, _v) {
const { value, done } = ge.next(_v)
if (done) {
ge.next(value)
} else {
@lili21
lili21 / rx.js
Last active August 14, 2017 06:12
observable
const observer = {
next: function nextCb(data) {
console.log(data)
},
error: function errorCb(error) {
console.error(error)
},
complete: function completeCb(data) {
@lili21
lili21 / decorator-ng-di.js
Last active August 14, 2017 06:13
decorator-ng-di
@Inject('ServiceA', 'ServiceB', 'ServiceC')
class Ctrl {
fetchData () {
this.ServiceA.fetch()
}
}
function Inject (...args) {
return function (target, key, descriptor) {
const ctrl = function (..._args) {
args.forEach((v, i) => {
git diff --name-only --cached --relative | grep '\\.js$' | xargs eslint