Skip to content

Instantly share code, notes, and snippets.

View jamesplease's full-sized avatar
🍕
yum

James Please jamesplease

🍕
yum
  • USA
View GitHub Profile
// Define some schemas
const schemas = {
books: booksSchema,
authors: authorsSchema
};
// Set an initial state
const initialState = {
books: {
resources: {

Resource Context API

Context Wrappers

This section is about createContext, Context.Provider and Context.Consumer usage

  • createContext – there will likely be a wrapper around this. createResourceContext?
  • Context.Provider is created for you, as users are not going to be in control of the value in Context
  • Users will likely use a wrapper of Context.Provider that sets up all of the individual resource providers (or maybe just one Provider, if I go the unstated route)

updating

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus sed urna ac luctus. Cras in neque vel felis porttitor rutrum quis nec dolor. Ut at urna ut diam semper convallis at et augue. Nulla pharetra sem at erat bibendum, vitae ornare orci commodo. Sed id ante facilisis, mollis libero at, cursus libero. Aenean interdum, lorem quis lacinia vulputate, augue ex dictum velit, ac feugiat mauris risus sit amet metus. Donec faucibus fringilla tortor, consectetur vestibulum urna tempor ut. Aliquam erat volutpat. Praesent iaculis nibh eu tortor vestibulum, eu cursus tellus dapibus. Vestibulum lobortis nibh elit, id egestas ante consectetur ac. Integer tempus sed massa eget hendrerit. Nullam arcu ante, porta vitae felis sed, pretium posuere sem. Nullam auctor leo at interdum commodo. Nullam ornare commodo magna, a maximus ante efficitur vel. Ut semper, ante in gravida condimentum, est velit dictum magna, ac fringilla elit felis quis erat.

Vestibulum ante ipsum primis in faucibus orci luctus et ul

{
id,
resourceType,
attributes,
meta,
relationships,
computedAttributes
}
@jamesplease
jamesplease / goals.md
Last active April 17, 2018 17:13
Goals for resource API

Goals

A resource system should:

  • Store information in a normalized fashion
  • Support subscriptions to the data and relationships returned from a request
  • Store and provide a system for accessing request status
  • Support n requests to retrieve data, with status aggregations

Stretch Goals

// This is a complete representation of an HTTP request
{
// Whether or not the request is finished. This means that no more
// data will be received. A request can be finished and errored, or
// finished and successful.
// Equal to:
// state === '
finished: {Boolean},

First, we start out with all null data. No responses have been received.

[null, null, null]

Then, a response returns:

[resOne, null, null]

Clone instead of reading the response.

fetch(input, init)
  .then(res => {
    // Store the response back from the server. This response will be
    // kept in an unused state. Anytime a user requests it, it will be
    // cloned from.
    cache[key] = {
 res,
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@jamesplease
jamesplease / thoughts.md
Last active April 11, 2018 16:37
PWA Thoughts

All /General

  • Scrolling down when the page is at the top should not move the header. In iOS, this can be fixed by avoiding position:sticky and using position:fixed. However, macOS PWAs via Chrome always scroll the header, even with position:fixed. This may(?) be an OS-level thing, since Safari on macOS also scrolls position:fixed

  • Likewise, that applies to anything pinned to the bottom of the page, such as a nav

  • Landing page for web should likely be different than landing page for standalone.