starfx
v0.13.4
RECT 앱을위한 마이크로 MVC 프레임 워크.
MVC의 관점에서 생각하면 react 가보기 인 경우 starfx 가 모델 및 컨트롤러 입니다.
시작하세요
특징:
import { createApi , createSchema , createStore , mdw , timer } from "starfx" ;
import { Provider , useCache } from "starfx/react" ;
const [ schema , initialState ] = createSchema ( ) ;
const store = createStore ( { initialState } ) ;
const api = createApi ( ) ;
// mdw = middleware
api . use ( mdw . api ( { schema } ) ) ;
api . use ( api . routes ( ) ) ;
api . use ( mdw . fetch ( { baseUrl : "https://api.github.com" } ) ) ;
const fetchRepo = api . get (
"/repos/neurosnap/starfx" ,
{ supervisor : timer ( ) } ,
api . cache ( ) ,
) ;
store . run ( api . bootup ) ;
function App ( ) {
return (
< Provider schema = { schema } store = { store } >
< Example />
</ Provider >
) ;
}
function Example ( ) {
const { isInitialLoading , isError , message , data } = useCache ( fetchRepo ( ) ) ;
if ( isInitialLoading ) return "Loading ..." ;
if ( isError ) return `An error has occurred: ${ message } ` ;
return (
< div >
< h1 > { data . name } </ h1 >
< p > { data . description } </ p >
< strong > ? { data . subscribers_count } </ strong > { " " }
< strong > { data . stargazers_count } </ strong > { " " }
< strong > ? { data . forks_count } </ strong >
</ div >
) ;
}