just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
/* | |
* override preact-router so we can synchronously change the route & trigger a render | |
* reason for doing this: often a UI action triggers an XHR which in turn will determine | |
* where the user needs to go next (it's a flashcard game, so whether they got it right or wrong | |
* will determine whether their session has concluded, whether to draw the next card, and so on) | |
* as a result we have a lot of action logic that wants to in one-fell-swoop programmatically route | |
* the user to a different component and also update the properties passed to the components by | |
* re-rendering (one big top-level render function, all state just passed by props, no stateful components) | |
* | |
* The practical effect of this change versus the built-in router was that it cuts the number of |
/** Usage: | |
* const MyView = unrecycle(props => { | |
* // this is normally a no-go and creates leaking styles, but it won't with unrecycle(): | |
* <input ref={ c => c && c.style.background='red' } /> | |
* }) | |
*/ | |
export default function unrecycle(Component) { | |
return function Unrecycle(props, context) { | |
this.componentWillUnmount = dontRecycle; | |
return Component.call(this, props, context); |
Domenic's blöcks proposal outlines a way to conveniently define functions that run in another worker/worklet as an inline, non-capturing scope, function body.
Blöcks as proposed have a few open questions and lack a few features that could generalize them to more use cases and with more practical ergonomics.
/** | |
* Copyright 2018 Google Inc. All Rights Reserved. | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and |
import { canRoute, customHistory, routeTo } from './preact-router.local'; | |
import { appRegistry, eventsService } from '../../../services/service-manager'; | |
/** | |
* Local setURL function overwrite from preact-router | |
* | |
* @param {string} url url, applied to router | |
* @param {string} type optional operation name, default = push | |
* @param {{ realURL: string, displayURL: string }} newState state object | |
*/ |
/** | |
* Copyright 2018 Google LLC | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
* use this file except in compliance with the License. You may obtain a copy of | |
* the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
import { watch as watchOnline } from 'is-offline'; | |
import Sockette from 'sockette'; | |
const msg_types = { | |
GQL_CONNECTION_INIT: 'connection_init', // Client -> Server | |
GQL_CONNECTION_ACK: 'connection_ack', // Server -> Client | |
GQL_CONNECTION_ERROR: 'connection_error', // Server -> Client | |
GQL_CONNECTION_TERMINATE: 'connection_terminate', // Client -> Server | |
GQL_START: 'start', // Client -> Server | |
GQL_DATA: 'data', // Server -> Client |
// Expected Queueing Time | |
// https://docs.google.com/document/d/1Vgu7-R84Ym3lbfTRi98vpdspRr1UwORB4UV-p9K1FF0/edit | |
// Initial impl by Nicolás Peña (npm), Tim Dresser (tdresser) | |
// Usage: | |
// var eqt = EQT.begin(); | |
// // ... | |
// const {expectedQueueingTime} = EQT.end(); | |
class EQT { | |
constructor() { |