seqflow-js
Advanced tools
Comparing version 0.0.1-beta.10 to 0.0.1-beta.11
{ | ||
"name": "seqflow-js", | ||
"version": "0.0.1-beta.10", | ||
"version": "0.0.1-beta.11", | ||
"description": "SeqFlow is a modern web framework that is designed to be simple and easy to use. It optimizes the development process by providing a simple and easy-to-understand API. It is a good choice for those who want to create web applications without the complexity of other frameworks.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.mjs", |
@@ -18,36 +18,33 @@ # SeqFlow JS | ||
```tsx | ||
import { start, SeqflowFunctionContext } from 'seqflow-js' | ||
import { SeqflowFunctionContext } from "seqflow-js"; | ||
async function Main(this: SeqflowFunctionContext) { | ||
let counter = 0 | ||
interface Quote { | ||
author: string; | ||
content: string; | ||
} | ||
const decrementButton = <button type="button">Decrement</button> | ||
const incrementButton = <button type="button">Increment</button> | ||
const counterDiv = <div>{counter}</div> | ||
this.renderSync( | ||
<> | ||
<div> | ||
{decrementButton} | ||
{incrementButton} | ||
</div> | ||
{counterDiv} | ||
</> | ||
) | ||
async function getRandomQuote(): Promise<Quote> { | ||
const res = await fetch("https://api.quotable.io/random") | ||
return await res.json(); | ||
} | ||
const events = this.waitEvents( | ||
this.domEvent('click', { el: this._el }) | ||
) | ||
for await (const ev of events) { | ||
if (ev.target === incrementButton) { | ||
counter++ | ||
} else if (ev.target === decrementButton) { | ||
counter-- | ||
} | ||
export async function Main(this: SeqflowFunctionContext) { | ||
// Render loading message | ||
this.renderSync( | ||
<p>Loading...</p> | ||
); | ||
counterDiv.textContent = `${counter}` | ||
} | ||
// Async operation may fail | ||
const quote = quote = await getRandomQuote(); | ||
// Replace loading message with quote | ||
this.renderSync( | ||
<div> | ||
<div>{quote.content}</div> | ||
<div>{quote.author}</div> | ||
</div> | ||
); | ||
} | ||
start(document.getElementById('root')!, Main) | ||
start(document.getElementById("root"), Main, undefined, {}); | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
266736
50