Skip to content

Instantly share code, notes, and snippets.

View daveols's full-sized avatar
🎯
Focusing

daveols

🎯
Focusing
View GitHub Profile
@daveols
daveols / main.dart
Last active February 29, 2024 22:36
Scrollable tabs within DraggableScrollableSheet
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@daveols
daveols / react-loads-diff-no-provider.md
Last active July 6, 2018 03:25
React Loads - use on individual loaders only
const App = () => (
-  <LoadsProvider>
    <Bacon />
-  </LoadsProvider>
)
@daveols
daveols / react-loads-loads-cache-provider.js
Created July 6, 2018 03:15
React Loads - loads level cache provider
const customCacheProvider = {
get: ...,
set: ...
}
const Bacon = () => (
<Loads cacheKey='bacon' cacheProvider={customCacheProvider} fn={getBacon}>
...
</Loads>
)
@daveols
daveols / react-loads-with-cache-provider.js
Created July 6, 2018 02:58
React Loads - loads provider with cacheProvider
import cacheProvider from './cache-providers/local-storage'
const App = () => (
<LoadsProvider cacheProvider={cacheProvider}>
<Bacon />
</LoadsProvider>
)
@daveols
daveols / react-loads-ls-cache-provider.js
Last active July 6, 2018 03:00
React Loads - local storage cache provider
const Global = typeof window !== 'undefined' ? window : global
const serialize = data => JSON.stringify(data)
const deserialize = stringValue => {
if (!stringValue) return
let value = ''
try {
value = JSON.parse(stringValue)
@daveols
daveols / react-loads-multiple-providers.js
Last active July 6, 2018 03:01
React Loads - with multiple providers
const withLoadsProvider = WrappedComponent => props => (
<LoadsProvider>
<WrappedComponent {...props}/>
</LoadsProvider>
)
const Router = createRoutes({
'/eggs': withLoadsProvider(Eggs),
'/bacon': withLoadsProvider(Bacon)
})
@daveols
daveols / react-loads-provider.js
Last active July 6, 2018 03:01
React Loads - with provider
import { LoadsProvider } from 'react-loads'
const Bacon = () => (
<Loads cacheKey='bacon' fn={getBacon}>
...
</Loads>
)
const App = () => (
<LoadsProvider>
@daveols
daveols / react-loads-basic.js
Last active July 6, 2018 03:02
React Loads - basic bacon example
const getBacon = () =>
axios.get('https://baconipsum.com/api/?type=meat-and-filler')
const Bacon = () => (
<Loads fn={getBacon}>
{({ isIdle, isLoading, isSuccess, response, load }) => (
<div>
<button onClick={load}>
{isIdle ? 'Get some bacon' : 'Get more bacon'}
</button>