Skip to content

Instantly share code, notes, and snippets.

View nsulistiyawan's full-sized avatar
🏠
Working from home

nsulistiyawan nsulistiyawan

🏠
Working from home
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function handleResults(results) {
const errors = results
.filter(result => result.status === 'rejected')
.map(result => result.reason)
if (errors.length) {
throw new AggregateError(errors)
}
return results.map(result => result.value)
async function loadInitialData() {
// fire and await together
const [userResult, productResult, otherResult] =
await Promise.allSettled([
fetchUser(), fetchProduct(), fetchOther()
])
// process user
if (userResult.status === 'rejected') {
function onReject(err) {
return err
}
async function loadInitialData() {
//fire and await together
const [user, product, other] = await Promise.all([
fetchUser().catch(onReject),
fetchProduct().catch(onReject)
async function loadInitialData() {
const userPromise = fetchUser();
const productPromise = fetchProduct();
const otherPromise = fetchOther();
// all of them running simultaneously
try {
const user = await userPromise;
async function loadInitialData(){
//let's assume that each request will take 600ms
try {
const user = await fetchUser(); // run 1st
const product = await fetchProduct(); // wait 600ms for user req to run
const other = await fetchOther(); // wait 600ms for product req to run
} catch(error) {
v -0.179050 1.274588 -0.040381
v -0.169976 1.289133 0.016252
v -0.290684 1.201673 -0.067585
v -0.226036 1.372423 -0.089406
v -0.254926 1.364176 0.000148
v -0.099124 1.420458 0.068408
v -0.221071 1.439538 0.015189
v -0.152510 1.440512 -0.105643
v -0.033935 1.328884 0.116747
v -0.324122 1.243871 -0.016855
@nsulistiyawan
nsulistiyawan / App.js
Last active May 1, 2022 00:44
lottie-splash-one
import React, {useState} from 'react';
import {Text, View, StyleSheet} from 'react-native';
import LottieView from 'lottie-react-native';
const App = () => {
const [lottieLoaded, setLottieLoaded] = useState(false);
if (!lottieLoaded) {
return (
<View style={styles.text}>
<script type="text/javascript" id="bloomerangForm2705410"></script>
<pre><script type="text/javascript">
var insertForm2705410 = function() {
var html2705410 = '<style text=\'text/css\'>' +
'.interaction-form label{color: #404040;' +
' display: block;}' +
'' +
'.interaction-form label.error{color:#900;' +
' display: inline-block; ' +
' padding: 0 10px;}' +
import React, { Fragment } from "react";
import { Link } from "react-router-dom";
import $ from "jquery";
import {
MDBNavbar,
MDBNavbarBrand,
MDBNavbarNav,
MDBNavItem,
MDBLink,
MDBNavbarToggler,