Разберем как сделать асинхронный запрос в апи для получения курса валюты. На react c useEffect это выглядит так:
import { useEffect, useState } from 'react';
OpenAPI (formerly Swagger) is a way to describe a REST API. It has slowly become a business standard, used by large tech companies as well as small. The Open Source community has built the OpenAPI specification to improve the reliability of REST APIs, with it you can define types and methods of an API. The community has also built tools to generate server and client code for these APIs.
The benefits of code generators are obviously having to write less code. There are many alternatives to generate clients, based on OpenAPI – most of them have issues. The issues are typically unorganized source code, being unmaintaned, outdated targets (the generated Typescript code is outdated) or being unfinished. These issues are the fundation of this proposal, which is essentially rewriting/building a OpenAPI to Typescript client generator.
Краткая характеристика:
Плюсы:
It's possible to render HTML in Preact using the dangerouslySetInnerHTML
prop,
however doing so bypasses the Virtual DOM entirely. This may be reasonable for
static HTML, but interactivity can be a little painful to graft on without VDOM.
There is another technique available that melds HTML to Virtual DOM without such limitations.
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
the command zig run my_code.zig
will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
declare const IS_ACTION_FETCH: unique symbol | |
/** | |
* Fetch fabric with statuses actions | |
* @param {(payload: Payload) => Promise<Result>} fetcher | |
* @param {{ | |
* onDone?: (result: Result, store: Store) => void | |
* onFail?: (error: unknown, store: Store) => void | |
* }} hooks | |
* @returns {{ |
// see cloudflare workers - https://workers.cloudflare.com | |
addEventListener('fetch', event => { | |
event.respondWith(fetchAndStream(event.request)) | |
}) | |
async function fetchAndStream(request) { | |
let streamResponse = fetch(request); // dont await, as majority of CF examples do | |
let { readable, writable } = new TransformStream() |
const { createServer } = require('http'); | |
createServer((req, res) => { | |
res.writeHead(200, { | |
Connection: 'Transfer-Encoding', | |
'Content-Type': 'text/html; charset=utf-8', | |
'Transfer-Encoding': 'chunked' | |
}); | |
res.write(` |
A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.
Syntax emits zero JavaScript.
type RESULT = VM<
[
["push", N_1], // 1
["push", False], // 2
["peek", _], // 3