This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef, useInsertionEffect, useCallback } from 'react'; | |
// Define a type for the event function | |
type EventFunction = (...args: any[]) => any; | |
export function useEvent<T extends EventFunction>(fn: T): T { | |
const ref = useRef<T | null>(null); | |
useInsertionEffect(() => { | |
ref.current = fn; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------- Lateset ---------------------------- | |
interface MemoStructure<_memoState, _index> { | |
state: _memoState; | |
index: _index; | |
memoAction: (memo: _memoState, _index: _index) => unknown;// this should be passed and used in func in the input of compute | |
} | |
class MemoMonad<_memoState, _index, S extends MemoStructure<_memoState, _index>> { | |
public memo: S; | |
public rootState?: _memoState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text-twoLine{ | |
overflow: hidden; | |
text-overflow: ellipsis; | |
display: -webkit-box; | |
-webkit-line-clamp: 2; /* number of lines to show */ | |
-webkit-box-orient: vertical; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* currying wrapper function that is magical | |
**/ | |
function curry(f) { | |
function curried(args) { | |
if (args.length >= f.length) return f(...args); | |
return accumulator; | |
function accumulator(a) { | |
return curried([...args, a]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 由其他generic type組成的會優先保持generic的描述,這樣無法“直接”看到單一property的值。 | |
* 用這個解構就可以看到property/value的值,debug或查詢蠻方便的。 | |
*/ | |
type FlatPrettified<T extends any> = { | |
[P in keyof T]:T[P] | |
} | |
/** | |
* 改變型別的Optional設定,在資料流的旅程中,有部分的路線是Optional的但又不想放寬整個型別設定。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import { useNavigate } from 'react-router-dom' | |
export function RouterMeta(props) { | |
let navigate = useNavigate(); | |
useEffect(()=>{ | |
console.log('RouterMeta navigate') | |
const href = window.location.href | |
const newPath = href.split('/?gh-pages-alter')[1] | |
if(newPath){ |