Micro front-end library
npm install web-gambitWeb-gambit - lightweight (5Kb) modular micro front-end library for creation progressive web-application on typescript. This library provide a powerful solution based on `Clean architecture principles.
Web-gambit - easy way for creating composition of micro fronted modules from remote sources! REP, CCP and CRP - its simple.
This solution is compatible with all popular frameworks: Vue, React, Angular, Svelte, Ember, etc.
`typescript
import {Module} from 'web-gambit'
type ModuleState = {index: number}
const ModuleNamespace = {moduleName: 'numeric', moduleState: {index: 12345}}
Module))`
`ts
import {Module, Emit, importModule, executeUmdModule} from 'web-gambit'
type CreatedDate = {getDate(): Date}
type UMD
const InstanceState = {createdDate: Date | null}
const InstanceNamespace = {moduleName: 'MainApp', moduleState: {createdDate: null}}
function fetchUmdModule
return importModule('/assets/modules/date/js/date.js').then(umdModule => {
const {exports} = executeUmdModule(umdModule) as UMD
return exports.default
})
}
Module
fetchUmdModule
Emit('createdDate', dateModule.getDate())
}).catch(console.log)
})
`
`typescript
import {Module, Emit} from 'web-gambit'
type InstanceState = {text: string}
const InstanceNamespace = {moduleName: 'MainApp', moduleState: {text: 'Hello World!'}}
Module
Watch({
name: 'watchUniqueName',
command: 'text',
action: (text: string) => console.log(text)
})
setInterval(() => Emit('text', Math.random().toString()), 300)
})
`
and render functions`typescript
import {createJsx as h, CreateApp, Module, CreateRouter, IRoute} from 'web-gambit'
import MainPage from './pages/main/MainPage'type IContent = {text: string}
const ModuleNamespace = {moduleName: 'contentView', moduleState: {text: 'Hello World!'}}
const routes: IRoute[] = [{path: '/', name: 'Main', component: MainPage}]
function SomeComponent() {
return h('div', null, [
h('h1', null, [ModuleNamespace.moduleState.text]),
CreateRouter(routes)
])
}
Module(ModuleNamespace, () => CreateApp(SomeComponent, document.getElementById('app')))
``