- CASE SENSITIVE EQUALS: Case-sensitive equality trumps all. These will be first. (ex.
France
would matchFrance
, but notfrance
) - EQUALS: Case-insensitive equality (ex.
France
would matchfrance
) - STARTS WITH: If the item starts with the given value (ex.
Sou
would matchSouth Korea
orSouth Africa
) - WORD STARTS WITH: If the item has multiple words, then if one of those words starts with the given value (ex.
Repub
would matchDominican Republic
) - CASE STARTS WITH: If the item has a defined case (
camelCase
,PascalCase
,snake_case
orkebab-case
), then if one of the parts starts with the given value (ex.kingdom
would matchunitedKingdom
orunited_kingdom
) - CASE ACRONYM If the item's case matches the synonym (ex.
uk
would matchunited-kingdom
orUnitedKingdom
) - CONTAINS: If the item contains the given word (ex.
America
would matchSouth America
) - ACRONYM: If the item's acronym is the given value (ex.
us
would mat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media all and (display-mode: standalone) { | |
body { | |
background-color: #000; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
return ( | |
<div> | |
{awaiting && <div>Still waiting to hear back...</div>} | |
{succeeded && <div>The request has succeeded!</div>} | |
{failed && <div>The request failed for some reason!</div>} | |
{streaming && <div>We have a response...receiving the data is underway</div>} | |
</div> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// The response was received, and the data is currently streaming. | |
// Note: this can be `true` even when the request fails (if the body of | |
// the error is being streamed) | |
streaming: <Boolean>, | |
// The response has not yet been returned by the server, OR it has been | |
// returned and the headers are still streaming (it appears that the headers) | |
// are immediately available at the same time that the Response object is | |
// made available to you) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// res.bodyUsed is true immediately after the method is called. That is awesome! | |
fetch('https://jsonplaceholder.typicode.com/posts/1') | |
.then(res => { | |
console.log('Immediately when the res is received:', res.bodyUsed); | |
const body = res.json() | |
.then(stuff => { | |
console.log('Ok response from res.json', stuff); | |
console.log('Body read as JSON', res.bodyUsed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchBook = createFetcher( | |
(options) => { | |
return fetch(`/books/${options.bookId}`); | |
}, | |
{ | |
attributeFetchers: { | |
author(bookId) { | |
return getAuthorForBookId(bookId) | |
} | |
} |
- Built on top of the Fetch API
- Split loading state into two Booleans (awaiting response and streaming)
- cancellation API, even if it is just "ignoring" the response
- API that maps to Promises. Likely a wrapper on top of the
Response
object - Partial success / partial failure (meaning one single response is returned with partial success. In other words, this is independent from streaming)
- Streaming (could be multiple requests making up the stream under-the-hood, or just one that is piping data to you gradually, i.e. JSONS)
- "Middleware" - could be a pattern rather than a library. It is just a pattern to transform data into useful formats. For instance, normalization middleware for inconsistent APIs.
- Each resource requires a "type" (book, author, comment, etc)
- Each resource requires an ID (a unique identifier. must be a string or a number)
- Stored in context (or a context polyfill)
- Data is normalized by ID
- A location for By-ID lookup
- Support for an arbitrary number of ordered lists (supports server-side ordering, and any situation when the client needs an ordered list or grouping of resources)
- Support for client-side metadata for resources (could be used for forms, or if data is modified, or
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Composer from 'react-composer'; | |
import Component from 'react-component-component'; | |
<Composer | |
components={[ | |
<Fetch {...fetchProps} />, | |
([firstResult]) => { | |
// Ultimately, you return a Fetch that is lazy. | |
// | |
// When `firstResult` changes from `loading` to succeeded, |