This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commonjs from '@rollup/plugin-commonjs'; | |
import resolve from '@rollup/plugin-node-resolve'; | |
import json from '@rollup/plugin-json'; | |
export default { | |
input: 'index.js', | |
output: { | |
dir: 'output', | |
format: 'cjs' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (req, res) => res.send('Hello World From Unikernel!')); | |
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
part 'car.d.dart'; | |
@JsonSerializable() | |
class Car { | |
String make; | |
String model; | |
// Default constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the json string from somewhere | |
String carJson = '{"make": "subaru", "model": "impreza"}'; | |
Map carMap = jsonDecode(carJson); | |
Car car = Car.fromJson(carMap); | |
// Work with car as usual | |
// ... | |
// Now send it back | |
String newCarJson = jsonEncode(car); | |
print(newCarJson); // {"make": "subaru", "model": "impreza"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car { | |
final String make; | |
final String model; | |
// Default constructor | |
Car(this.make, this.model); | |
Car.fromJson(Map<String, dynamic> json) | |
: make = json['make'], | |
model = json['model']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:graphql_flutter/graphql_flutter.dart'; | |
import 'package:todo_graphql_tutorial/api.dart'; | |
void main() => runApp(TodoApp()); | |
class TodoApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/foundation.dart'; | |
import 'package:graphql_flutter/graphql_flutter.dart'; | |
ValueNotifier<GraphQLClient> client = ValueNotifier( | |
GraphQLClient( | |
cache: InMemoryCache(), | |
link: HttpLink(uri: 'http://10.0.2.2:3000'), | |
), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:10 | |
# Create app directory | |
WORKDIR /usr/src/app | |
# Install app dependencies | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied | |
# where available (npm@5+) | |
COPY package*.json ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example with Redux Toolkit | |
import React from 'react'; | |
import {createAction, createReducer, configureStore} from 'redux-toolkit'; | |
import {Provider, useSelector, useDispatch} from 'react-redux'; | |
const initialState = {counter: 0}; | |
const increment = createAction('INCREMENT'); | |
const reducer = createReducer(initialState, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EXAMPLE WITH REDUX | |
import React from 'react'; | |
import {createStore} from 'redux'; | |
import {Provider, useSelector, useDispatch} from 'react-redux'; | |
const initialState = {counter: 0}; | |
const reducer = (state=initialState, action) => { | |
switch (action.type) { | |
case 'INCREMENT': |