All works just like Promise.all() in Javascript and waits for all channels to return a value. After returning a list of values output channel is closed.
type IntValue struct {
Value int
}
func main() {
values := <-All(
const interceptCallsTo = (() => { | |
const pad = (value) => String(value).padStart(2, '0'); | |
const getTime = (date = new Date()) => | |
`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad( | |
date.getSeconds(), | |
)}.${pad(date.getMilliseconds())}`; | |
return (obj, props = []) => { | |
const filtered = props && props.length; |
<!-- | |
This conains an input field for a JS command and output area to displaying whatever your command returns. | |
To execute command press Enter key or push "Execute" button on the right(if Enter key is being captured). | |
--> | |
<div style="width: 100%; display: flex; flex-direction: column; align-items: stretch;"> | |
<div style="display: flex; margin: 5px; align-items: center;"> | |
<input id="console-input" style="font-family: monospace; margin-right: 5px; flex: 1;"> | |
<button id="console-exec">Execute</button> | |
</div> | |
<div id="console-output" style="white-space: pre-line; font-family: monospace; margin: 5px; border: 1px solid #000; padding: 5px;"> |
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func seconds(done <-chan int) <-chan time.Time { | |
out := make(chan time.Time) |
import PropTypes from 'prop-types'; | |
import callIfFunction from '@actualwave/call-if-function'; | |
import withConnected from './withConnected'; | |
const Offline = ({ connected, children, onlineRenderer }) => { | |
if (connected) { | |
return callIfFunction(onlineRenderer); | |
} |
import { View } from 'react-native'; | |
import withLayoutProps from './withLayoutProps'; | |
export const Layout = withLayoutProps(View, true, true, 'Layout'); |
callIfFunction
accepts multiple arguments and checks first one.
If it is a function, it will be called with other arguments passed to it(just like for Function.call())
If it is not a function, then value from first argument wil be returned.
I use it in react components, to check if component children are react nodes or a renderer function.