Fastpack - pack JavaScript fast & easy
This gist is a submission for a lightning talk on the ReactiveConf 2018.
- JavaScript bundling can be a lot faster
- There are proper tools to guarantee consistency
- Writing OCaml code is fun!
module Menu = { | |
[@bs.module "@reach/menu-button"] [@react.component] | |
external make: | |
(~className: string=?, ~children: React.element) => React.element = | |
"Menu"; | |
module Button = { | |
[@bs.module "@reach/menu-button"] [@react.component] | |
external make: (~children: React.element) => React.element = "MenuButton"; | |
}; |
const {useCallback, useEffect, useReducer, useRef} = require('react'); | |
let effectCapture = null; | |
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) { | |
let updateCounter = useRef(0); | |
let wrappedReducer = useCallback(function(oldWrappedState, action) { | |
effectCapture = []; | |
try { | |
let newState = reducer(oldWrappedState.state, action.action); |
This gist is a submission for a lightning talk on the ReactiveConf 2018.
# Name it whatever you want. I like `y` because in my keyboard layout it's close to `;` | |
function y() { | |
previous=$? | |
if [ $previous -eq 0 ]; then | |
osascript -e "display notification \"Done\" with title \"Terminal Task\"" && say "it is done"; | |
else | |
osascript -e "display notification \"Failed\" with title \"Terminal Task\"" && say "it went to the trees"; | |
fi | |
} |
Elm is a statically typed functional language that compiles to JavaScript. It's well-known for its developer experience: the compiler provides nice error messages, the package system enforces semantic versioning for all published packages and makes sure every exposed value or type has some documentation and type annotations.
React is an amazing library for client-side user interface, and it has the added benefit of being able to be rendered on the server, which is crucial for SEO, SEM, and user experience. However, server-side rendering in practice is significantly more complicated than just calling ReactDOMServer.renderToString and piping out the result, especially if you want to make sure your site loads quickly in a mobile-first world. React Server smoothes out the common problems you run into with React server-side rendering, encodes performance best practices into the framework, and makes it easy to build high performance websites by default.
I'll discuss some of the design decisions we made during development, show our performance improvements, talk about lessons we've learned running React Server in production for a year and a half, and give some hints about the future of React Server, including adding streaming to React core.
Proposal for lightning talk at Reactive Conference.
===
React Native for macOS (a.k.a React Native Desktop) started as an experiment a year ago, just out of curiousity and the active stage of development also took place during the previous Reactive conference right in the hotel room in Bratislava.
5 minutes talk about why you probably haven't heard about any real desktop application based on RN, and for what kind of applications it might be perfect fit.
Redux has brought the notion of reducer back into the awareness of many developers for whom they are a novel concept. In fact they are quite simple, and used all the time in such things as SUM
aggregations in databases, where they compute a single value from many.
It's great that Redux has made reducers known to a broader audience, though they are relatively ancient concepts in programming, in fact. But the particular way Redux illustrates a reducer in its documentaion is, in my opinion, with a coding style that is harder to extend and read than it should be. Let's distill reducers down to their essensce, and build up Redux reducers in a way that lowers complexity, and helps separate Redux idioms from your business logic.
A reducer is a pure function that accepts more arguments than it returns. That is to say - one whose "arity" is greater than 1. It 'reduces' the two things you pass it down to a single value. Here are two reducers, in a map
if (typeof Promise === 'undefined') { | |
require.ensure([], (require) => { | |
require('imports?this=>window!es6-promise') | |
}) | |
} | |
if (typeof fetch === 'undefined') { | |
require.ensure([], (require) => { | |
require('imports?self=>window!whatwg-fetch') | |
}) |
(function (root, factory) { | |
"use strict"; | |
if (typeof define === 'function' && define.amd) { | |
define(['moment'], factory); | |
} else if (typeof exports === 'object') { | |
module.exports = factory(require('moment')); | |
} else { | |
factory(root.moment); | |
} | |
}(this, function (moment) { |