Async Programming All in One

Async Programming All in One

Async & Await

Frontend

(async () => {
	const url = "https://cdn.xgqfrms.xyz/json/awesome-developer.json"
	const result = await fetch(url).json()

	if(result.name == `xgqfrms`) {
		alert('You are awesome!')
	} else {
		alert('You are awesome too!')
	}
})();

Backend

#!/usr/bin/env python
import asyncio as io
import websockets as ws

async def hello(websocket, path):
		name = await websocket.recv()
		greeting = f"Hello {name}!"
		await websocket.send(greeting)

server = ws.serve(hello, 'localhost', 1337)
io.get_event_loop().run_until_complete(server)
io.get_event_loop().run_forever()


Mobile APP

import 'package:flutter/widgets.dart';
void main() {
 runApp(
  const Center(
   child: Text(
    'Hello, world!',
    textDirection: TextDirection.ltr
   )
  )
 );
}

DevOps

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:8.11.2
    working_directory: ~/codedamn

    steps:
      - checkout
      - run: 
          name: Install Dependencies
          command: npm install
      - run: npm run test

refs

https://codedamn.com/

vim

Async Programming All in One_第1张图片


Flag Counter

©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


你可能感兴趣的:(Async Programming All in One)