• Stars
    star
    524
  • Rank 84,541 (Top 2 %)
  • Language
    TypeScript
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Square Svelte Store

Extension of svelte default stores for dead-simple handling of complex asynchronous behavior.

What it does

Square Svelte Store builds upon Svelte's default store behavior to empower your app to reactively respond to asynchronous data. Familiar syntax lets you build out async stores as easily as the ones you are already using, with full compatibility between them. Behind-the-scenes smarts handle order of operations, lazy loading, and limiting network calls, allowing you to focus on the relationships between data.

A preview...

// You can declare an asyncDerived store just like a derived store,
// but with an async function to set the store's value!
const searchResults = asyncDerived(
  [authToken, searchTerms],
  async ([$authToken, $searchTerms]) => {
    const rawResults = await search($authToken, $searchTerms);
    return formatResults(rawResults);
  }
);

The Basics

Square Svelte Store is intended as a replacement for importing from svelte/store. It includes all of the features of svelte/store while also adding new stores and extending functionality for compatibility between them.

Loadable

Stores exported by @square/svelte-store are a new type: Loadable. Loadable stores work the same as regular stores--you can derive from them, subscribe to them, and access their value reactively in a component by using the $ accessor. But they also include extra functionality: a load function is available on every store. This function is asynchronous, and resolves to the value of the store after it has finished its async behavior. This lets you control the display of your app based on the status of async routines while also maintaining reactivity!

{#await myLoadableStore.load()}
 <p>Currently loading...</p>
{:then}
 <p>Your loaded data is: {$myLoadableStore}</p>
{/await}

What's better is that any derived store loads all of its parents before loading itself, allowing you to awaitloading of the derived store to automatically wait for all required data dependencies. This means that no matter how complex the relationships between your async and synchronous data gets you will always be able to ensure that a given store has its final value simply by awaiting .load()!

Reloadable

While hydrating your app with data, some endpoints you will only need to access once. Others you will need to access multiple times. By default async stores will only load once unless a store they derive from changes. However if you would like an async store to be able to load new data you can declare it to be reloadable during creation. If you do so, the store, and any stores that ultimately derive from it, will have access to a reload function. Calling the reload function of a Reloadable store will cause it fetch new data, and calling the reload function of any store that derives from a Reloadable store will cause that Reloadable store to reload. In this manner you can call reload on a store and it will reload any sources of data that should be refreshed without unnecessarily creating promises for data that should not be refreshed.

The New Stores

asyncReadable

An asyncReadable store provides easy asynchronous support to readable stores. Like a readable store, an asyncReadable store takes in an initial value and a function that is called when the store is first subscribed to. For an asyncReadable store this function is an async loadFunction which takes no arguments and returns the loaded value of the store. An optional third parameter can specify options for the store, in this case declaring it to be reloadable.

asyncReadable stores are super simple! Let's see it in action...

const userInfo = asyncReadable(
  {},
  async () => {
    const response = await fetch('https://ourdomain.com/users/info');
    const userObject = await response.json();
    return userObject;
  },
  { reloadable: true }
);

Now we have a Loadable and reloadable userInfo store! As soon as our app renders a component that needs data from userInfo it will begin to load. We can {#await userInfo.load()} in our components that need userInfo. This will delay rendering until we have the data we need. Since we have declared the store to be reloadable we can call userInfo.reload() to pull new data (and reactively update our components once we have it).

derived

Okay this isn't a new store, but it does have some new features! We declare a derived store the same as ever, but it now gives us access to a load function. This load function resolves after all parents have loaded and the derived store has calculated its final value.

What does that mean for our app..?

const userSettings = derived(userInfo, ($userInfo) => $userInfo?.settings);
const darkMode = derived(userSettings, ($userSetting) => $userSettings?.darkMode);

Now we've got a darkMode store that tracks whether our user has selected darkMode for our app. When we use this store in a component we can call darkMode.load(). This awaits userSettings loading, which in turn awaits userInfo. In this way, we can load a derived store to automatically load the sources of its data and to wait for its final value. What's more, since darkMode derives from a reloadable source, we can call darkMode.reload() to get new userInfo if we encounter a situation where the user's darkMode setting may have changed.

This isn't very impressive with our simple example, but as we build out our app and encounter situations where derived values come fom multiple endpoints through several layers of derivations this becomes much more useful. Being able to call load and reload on just the data you need is much more convenient than tracking down all of the dependencies involved!

asyncDerived

An asyncDerived store works just like a derived store, but with an asynchronous call to get the final value of the store!

Let's jump right in...

const results = asyncDerived(
  [authToken, page],
  async ([$authToken, $page]) => {
    const requestBody = JSON.stringify({ authorization: $authToken });
    const response = await fetch(
      `https://ourdomain.com/list?page=${$page}`,
      requestBody
    );
    return response.json();
  }
);

Here we have a store that reflects a paginated set of results from an endpoint. Just like a regular derived store we include a function that maps the values of parent stores to the value of this store. Of course with an async store we use an async function. However, while regular derived stores will invoke that function whenever any of the parent values changes (including initialization) an asyncDerived store will only do so after all of the parents have finished loading. This means you don't need to worry about creating unnecessary or premature network calls.

After the stores have finished loading any new changes to the parent stores will create a new network request. In this example if we write to the page store when the user changes pages we will automatically make a new request that will update our results store. Just like with asyncReadable stores we can include a boolean to indicate that an asyncDerived store will be Reloadable.

asyncWritable

Here's where things get a little more complicated. Just like the other async stores this store mirrors an existing store. Like a regular writable store this store will have set and update functions that lets you set the store's value. But why would we want to set the value of the store if the store's value comes from a network call? To answer this let's consider the following use case: in our app we have a list of favorite shortcuts for our user. They can rearrange these shortcuts in order to personalize their experience. When a user rearranges their shortcuts we could manually make a new network request to save their choice, then reload the async store that tracks the list of shortcuts. However that would mean that the user would not see the results of their customization until the network request completes. Instead we can use an asyncWritable store. When the user customizes their list of shortcuts we will optimistically update the corresponding store. This update kicks off a network request to save the user's customization to our backend. Finally, when the network request completes we update our store to reflect the canonical version of the user's list.

So how do we accomplish this using an asyncWritable store..?

const shortcuts = asyncWritable(
  [],
  async () => {
    const response = await fetch('https://ourdomain.com/shortcuts');
    return response.json();
  },
  async (newShortcutsList) => {
    const postBody = JSON.stringify({ shortcuts: newShortcutsList });
    const response = await fetch('https://ourdomain.com/shortcuts', {
      method: 'POST',
      body: postBody,
    });
    return response.json();
  }
);

Our first two arguments work just like an asyncDerived store--we can pass any number of stores and we can use their values to set the value of the store once the parents have loaded. If we don't need to derive from any store we can pass [] as our first argument. For our third argument we optionally provide a write function that is invoked when we set or update the value of the store ourself. It takes in the new value of the store and then performs the work to persist that to the backend. If we invoke shortcuts.set() first the store updates to the value we pass to the function. Then it invokes the async function we provided during definition in order to persist the new data. Finally it sets the value of the store to what we return from the async function. If our endpoint does not return any useful data we can instead have our async function return void and skip this step.

One final feature is that we can include a second argument for our write function that will receive the values of parent stores.

Let's look at what that looks like...

const shortcuts = asyncWritable(
  authToken,
  async ($authToken) => {
    const requestBody = JSON.stringify({ authorization: $authToken });
    const response = await fetch(
      'https://ourdomain.com/shortcuts',
      requestBody
    );
    return response.json();
  },
  async (newShortcutsList, $authToken) => {
    const postBody = JSON.stringify({
      authorization: $authToken,
      shortcuts: newShortcutsList,
    });
    const response = await fetch('https://ourdomain.com/shortcuts', {
      method: 'POST',
      body: postBody,
    });
    return response.json();
  }
);

In this example we derive from an authToken store and include it in both our GET and POST requests.

Some niche features of asyncWritable stores allow for more specific error handling of write functions. The write function we provide as the third argument can be written to accept a third argument that receives the value of the store before it was set. This allows for resetting the value of the store in the case of a write failure by catching the error and returning the old value. A similar feature is that both the set and update functions can take a second argument that indicates whether the async write functionality should be called during the set process.

readable/writable

Similarly to derived stores, addtional load functionality is bundled with readable and writable stores. Both readable and writable stores include a .load() function that will resolve when the value of the store is first set. If an initial value is provided when creating the store, this means the store will load immeadietly. However, if a value is not provided (left undefined) then the store will only load after it is set to a value. This makes it easy to wait on user input, an event listener, etc. in your application.

It's easy to wait for user input...

<script>
  const hasConsent = writable((set) => {
    const setConsent = () => set(true);
    addEventListener('CONSENT_EVENT', setConsent);

    return () => removeEventListener('CONSENT_EVENT', setConsent);  
  });
  const needsConsent = asyncDerived(
    (hasConsent),
    async ($hasConsent) => {
      // this won't run until hasConsent has loaded
      if (!$hasConsent) {
        return "no consent given"
      }
      const asyncMessage = await Promise.resolve('data fetched from server');
      return asyncMessage;
    }
  );
</script>

<button on:click={() => hasConsent.set(true)>I consent!</button>
<button on:click={() => hasConsent.set(false)>I don't consent!</button>

{#await needsConsent.load()}
  <p>I will only load after hasConsent has been populated</p>
  <p>{$needsConsent}</p>
{/await}

persisted

Sometimes data needs to persist outside the lifecycle of our app. By using persisted stores you can accomplish this while gaining all of the other benefits of Loadable stores. A persisted store synchronizes (stringifiable) store data with a sessionStorage item, localStorage item, or cookie. The persisted store loads to the value of the corresponding storage item, if found, otherwise it will load to the provided initial value and persist that value to storage. Any changes to the store will also be persisted!

We can persist a user name across page loads...

<script>
  // if we don't specify what kind of storage, default to localStorage
  const userName = persisted('John Doe', 'USER_DATA');
</script>

// If we reload the page, this input will still have the same value!
<input bind:value={$userName}>

If data isn't already in storage, it may need to be fetched asynchronously. In this case we can pass a Loadable store to our persisted store in place of an initial value. Doing so will load the Loadable store if no storage item is found and then synchronize the persisted store and storage with the loaded value. We can also declare the persisted store to be reloadable, in which case a call to .reload() will attempt to reload the parent Loadable store and persist the new data to storage.

Persisting remote data is simple...

const remoteSessionToken = asyncReadable(
  undefined, 
  async () => {
    const session = await generateSession();
    return session.token;
  },
  { reloadable: true },
);

const sessionToken = persisted(
  remoteSessionToken,
  'SESSION_TOKEN',
  { reloadable: true, storageType: 'SESSION_STORAGE' }
);

With this setup we can persist our remote data across a page session! The first page load of the session will load from the remote source, but successive page loads will use the persisted token in session storage. What's more is that because Loadable stores are lazily loaded, remoteSessionToken will only fetch remote data when its needed for sessionToken (provided there are no other subscribers to remoteSessionToken). If our session token ever expires we can force new data to be loaded by calling sessionToken.reload()!

If an external source updates the storage item of the persisted store the two values will go out of sync. In such a case we can call .resync() on the store in order to update the store the parsed value of the storage item.

We are also able to wipe stored data by calling clear() on the store. The storage item will be removed and the value of the store set to null.

persisted configuration / custom storage

Persisted stores have three built in storage types: LOCAL_STORAGE, SESSION_STORAGE, and COOKIE. These should be sufficient for most use cases, but have the disadvantage of only being able to store JSON serializable data. If more advanced behavior is required we can define a custom storage type to handle this, such as integrating IndexedDB. All that is required is for us to provide the relevant setter/getter/deleter functions for interfacing with our storage.

One time setup is all that is needed for custom storage...

configureCustomStorageType('INDEXED_DB', {
  getStorageItem: (key) => /* get from IndexedDB */,
  setStorageItem: (key, value) => /* persist to IndexedDB */,
  removeStorageItem: (key) => /* delete from IndexedDB */,
});

const customStore = persisted('defaultValue', 'indexedDbKey', {
  storageType: 'INDEXED_DB',
});

persisted configuration / consent

Persisting data to storage or cookies is subject to privacy laws regarding consent in some jurisdictions. Instead of building two different data flows that depend on whether tracking consent has been given or not, you can instead configure your persisted stores to work in both cases. To do so you will need to call the configurePersistedConsent function and pass in a consent checker that will accept a consent level and return a boolean indicating whether your user has consented to that level of tracking. You can then provide a consent level when building your persisted stores that will be passed to to the checker before storing data.

GDPR compliance is easy...

configurePersistedConsent(
  (consentLevel) =>  window.consentLevels.includes(consentLevel);
);

const hasDismissedTooltip = persisted(
  false, 
  'TOOLTIP_DISMISSED', 
  { 
    storageType: 'COOKIE',
    consentLevel: 'TRACKING'
  }
);

Here we hypothesize a setup where a user's consentLevels are accessible through the window object. We would like to track the dismissal of a tooltip and ideally persist that across page loads. To do so we set up a hasDismissedTooltip store that can bet set like any other writable store. If the user has consented to the TRACKING consent level, then setting the store will also set a TOOLTIP_DISMISSED cookie. Otherwise no data will be persisted and the store will initialize to the default value false on each page load.

Note that if no consent level is provided, undefined will be passed to the consent checker. This can be handled to provide a default consent for your persisted stores when a consent level is not provided.

state

State stores are a kind of non-Loadable Readable store that can be generated alongside async stores in order to track their load state. This can be done by passing the trackState to the store options during creation. This is particular useful for reloadable or asyncDerived stores which might go into a state of pulling new data.

State stores can be used to conditionally render our data...

<script>
  let searchInput;
  const searchTerms = writable();
  const {store: searchResults, state: searchState} = asyncDerived(
    searchTerms,
    async ($searchTerms) => {
      const response = await search($searchTerms);
      return response.results;
    },
    { trackState: true }
  )
</script>

<input bind:value={searchInput}>
  <button on:click={() => searchTerms.set(searchInput)}>search</button>
  {#if $searchState.isLoading}
    <SearchTips />
  {:else if $searchState.isLoaded}
    <SearchResults results={$searchResults} />
  {:else if $searchState.isReloading}
    <ActivityIcon />
    <SearchResults results={$searchResults} />
  {:else if $searchState.isError}
    <SearchError />
  {/if}
<input >

We are able to easily track the current activity of our search flow using trackState. Our searchState will initialize to LOADING. When the searchTerms store is first set it will load, which will kick off searchTerms own loading process. After that completes searchState will update to LOADED. Any further changes to searchTerms will kick off a new load process, at which point searchTerms will update to RELOADING. We are also able to check summary states: isPending is true when LOADING or RELOADING and isSettled is true when LOADED or ERROR.

Note that trackState is (currently) only available on asyncStores -- asyncReadable, asyncWritable, and asyncDerived.

asyncClient

An asyncClient is a special kind of store that expands the functionality of another Loadable store. Creating an asyncClient allows you to start accessing the propeties of the object in your store before it has loaded. This is done by transforming all of the object's properties into asynchronous functions that will resolve when the store has loaded.

Confusing in concept, but simple in practice...

const logger = asyncClient(readable(
  undefined,
  (set) => {
    addEventListener('LOGGING_READY', () => {
      set({
        logError: (error) => window.log('ERROR', error.message),
        logMessage: (message) => window.log('INFO', message),
      });
    })
  }
));

logger.logMessage('Logging ready');

In this example we assume a hypothetical flow where a LOGGING_READY event is fired upon an external library adding a generic logger to the window object. We create a readable store that loads when this event fires, and set up an object with two functions for logging either errors or non-error messages. If we did not use an asyncClient we would need to call logMessage like so: logger.load().then(($logger) => $logger.logMessage('Logging ready')) However, by turning the readable store into an asyncClient we can instead call logger.logMessage immeadietly and the message will be logged when the LOGGING_READY event fires.

Note that the asyncClient is still a store, and so can perform all of the store functionality of what it wraps. This means, for example, that you can make an asyncClient of a writable store and have access to the set and update functions.

Non-function properties of the object loaded by the asyncClient can also be accessed using an async function. I.e. if an asyncClient loads to {foo: 'bar'}, myClient.foo() will resolve to 'bar' when the asyncClient has loaded. The property access for an asyncClient is performed dynamically, and that means that any property can attempt to be accessed. If the property can not be found when the asyncClient loads, this will resolve to undefined. It is recommended to use typescript to ensure that the accessed properties are members of the store's type.

If a store loads directly to a function, an asyncClient can be used to asynchronously invoke that function.

We can call loaded functions easily...

const logMessage = asyncClient(readable(
  undefined,
  (set) => {
    addEventListener('LOGGING_READY', () => {
      set((message) => window.log('INFO', message));
    })
  }
));

logMessage('Logging ready')

Instead of defining a store that holds an object with function properties, we instead have the store hold a function directly. As before, logMessage will be called when the LOGGING_READY event fires and the store loads.

Additional functions

isLoadable and isReloadable

The isLoadable and isReloadable functions let you check if a store is Loadable or Reloadable at runtime.

loadAll

The loadAll function can take in an array of stores and returns a promise that will resolve when any loadable stores provided finish loading. This is useful if you have a component that uses multiple stores and want to delay rendering until those stores have populated.

safeLoad

The safeLoad function works similarly to loadAll, however any loading errors of the given stores will be caught, and a boolean returned representing whether loading all of the provided stores was performed successfully or not. This can be useful when you wish to handle possible loading errors, yet still want to render content upon failure.

{#await safeLoad(myStore) then loadedSuccessfully}
  {#if !loadedSuccessfully}
    <ErrorBanner/>
  {/if}
  <ComponentContent/>
{/await}

logAsyncErrors

Using safeLoad or {#await}{:then}{:catch} blocks in templates allows you to catch and handle errors that occur during our async stores loading. However this can lead to a visibility problem: if you always catch the errors you may not be aware that your users are experiencing them. To deal with this you can pass an error logger into the logAsyncErrors function before you set up your stores. Then any time one of our async stores experiences an error while loading it will automatically call your error logging function regardless of how you handle the error downstream.

aborting / rebounce (BETA)

Async functionality based on user input is prone to subtle race conditions and async stores are no exception. For example, imagine you want to get a paginated list of items. When the user changes pages a new request is made and then assigned to a currentItems variable. If a user changes pages quickly the requests to the items endpoint may resolve in a different order than they were made. If this happens, currentItems will reflect the last request to resolve, instead of the last request to be made. Thus the user will see an incorrect page of items.

The solution for this problem is to abort old requests and to only resolve the most recent one. This can be performed on fetch requests using abort controllers. To support this pattern, async stores have special handling for rejections of aborted requests. If a store encounters an abort rejection while loading, the store's value will not update, and the rejection will be caught.

While fetch requests have built in abort controller support, async functions do not. Thus the rebounce function is provided. It can be used to wrap an async function and automatically abort any in-flight calls when a new call is made.

Use rebounce to abort stale async calls...

let currentItems;

const getItems = async (page) => {
  const results = await itemsRequest(page)
  return results.items;
}

const rebouncedGetItems = rebounce(getItems)

const changePage = async (page) => {
  currentItems = await rebouncedGetItems(page);
}

changePage(1);
changePage(2);
changePage(3);

Without using rebounce, currentItems would end up equaling the value of getItems that resolves last. However, when we called the rebounced getItems it will equal value of getItems that is called last. This is because a rebounced function returns a promise that resolves to the returned value of the function, but this promise is aborted when another call to the function is made. This means that when we call changePage three times, the first and second calls to rebouncedGetItems will reject and only the third call will update currentItems.

Using rebounce with stores is straight forward...

const rebouncedGetItems = rebounce(
  async (page) => {
    const results = await itemsRequest(page)
    return results.items;
  },
  200
);

const currentItems = asyncDerived(page, ($page) => {
  return rebouncedGetItems($page);
});

Here we have created a store for our currentItems. Whenever we update the page store we will automatically get our new items. By using rebounce, currentItems will always reflect the most up-to-date page value. Note we have also provided a number when calling rebounce. This creates a corresponding millisecond delay before the rebounced function is called. Successive calls within that time frame will abort the previous calls before the rebounced function is invoked. This is useful for limiting network requests. In this example, if our user continues to change the page, an itemsRequest will not be made until 200 ms has passed since page was updated. This means, if our user rapidly clicks through pages 1 to 10, a network request will only be made (and our currentItems store updated) when they have settled on page 10.

NOTES:

  • In flight rebounces can be manually aborted using clear. rebouncedFunction.clear()
  • Aborting an async function will cause it to reject, but it will not undo any side effects that have been created! Therefore it is critical that side effects are avoided within the rebounced function. Instead they should instead be performed after the rebounce has resolved.

Putting it all Together

The usefulness of async stores becomes more obvious when dealing with complex relationships between different pieces of async data.

Let's consider an example scenario that will put our @square/svelte-stores to work. We are developing a social media website that lets users share and view blogs. In a sidebar we have a list of shortcuts to the users favorite blogs with along with a blurb from their most recent post. We would like to test a feature with 5% of users where we also provide a few suggested blogs alongside their favorites. As the user views new blogs, their suggested list of blogs also updates based on their indicated interests. To support this we have a number of endpoints.

  • A personalization endpoint provides a list of the user's favorite and suggested blogs.
  • A preview endpoint lets us fetch a blurb for the most recent post of a given blog.
  • A favorites endpoint lets us POST updates a user makes to their favorites.
  • A testing endpoint lets us determine if the user should be included in the feature test.
  • A user endpoint lets us gather user info, including a token for identifying the user when calling other endpoints.

We've got some challenges here. We need the user's ID before we take any other step. We need to query the testing endpoint before we will know whether to display suggestions alongside favorites. And whenever a users shortcuts update we'll need to update our preview blurbs to match.

Without async stores this could get messy! However by approaching this using stores all we need to worry about is one piece of data at a time, and the pieces we need to get it.

Let's look at an interactive implementation...

Extras

If you are using eslint, eslint-plugin-square-svelte-store will enforce usage of square-svelte-store and can be used to autofix usages of svelte/store.

// .eslintrc.js
module.exports = {
  plugins: ['square-svelte-store'],
  rules: {'square-svelte-store/use-square-svelte-stores': 'error'}
}

Testing

Testing mode can be enabled using the enableStoreTestingMode function before running your tests. If testing mode is enabled async stores will include an additional function, reset. This function can be called in between tests in order to force stores to reset their load state and return to their initial value. This is useful to test different load conditions for your app, such as endpoint failures.

More Repositories

1

okhttp

Squareโ€™s meticulous HTTP client for the JVM, Android, and GraalVM.
Kotlin
45,794
star
2

retrofit

A type-safe HTTP client for Android and the JVM
HTML
43,053
star
3

leakcanary

A memory leak detection library for Android.
Kotlin
29,383
star
4

picasso

A powerful image downloading and caching library for Android
Kotlin
18,716
star
5

javapoet

A Java API for generating .java source files.
Java
10,820
star
6

moshi

A modern JSON library for Kotlin and Java.
Kotlin
9,756
star
7

okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
Kotlin
8,790
star
8

dagger

A fast dependency injector for Android and Java.
Java
7,308
star
9

crossfilter

Fast n-dimensional filtering and grouping of records.
JavaScript
6,217
star
10

PonyDebugger

Remote network and data debugging for your native iOS app using Chrome Developer Tools
Objective-C
5,864
star
11

maximum-awesome

Config files for vim and tmux.
Ruby
5,706
star
12

otto

An enhanced Guava-based event bus with emphasis on Android support.
Java
5,163
star
13

cubism

Cubism.js: A JavaScript library for time series visualization.
JavaScript
4,943
star
14

sqlbrite

A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations.
Java
4,570
star
15

android-times-square

Standalone Android widget for picking a single date from a calendar view.
Java
4,445
star
16

wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
Kotlin
4,244
star
17

Valet

Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโ€™s easy. We promise.
Swift
3,989
star
18

cube

Cube: A system for time series visualization.
JavaScript
3,904
star
19

kotlinpoet

A Kotlin API for generating .kt source files.
Kotlin
3,896
star
20

java-code-styles

IntelliJ IDEA code style settings for Square's Java and Android projects.
Shell
2,957
star
21

flow

Name UI states, navigate between them, remember where you've been.
Java
2,786
star
22

spoon

Distributing instrumentation tests to all your Androids.
HTML
2,702
star
23

keywhiz

A system for distributing and managing secrets
Java
2,619
star
24

tape

A lightning fast, transactional, file-based FIFO for Android and Java.
Java
2,466
star
25

certstrap

Tools to bootstrap CAs, certificate requests, and signed certificates.
Go
2,282
star
26

mortar

A simple library that makes it easy to pair thin views with dedicated controllers, isolated from most of the vagaries of the Activity life cycle.
Java
2,157
star
27

go-jose

An implementation of JOSE standards (JWE, JWS, JWT) in Go
1,975
star
28

Cleanse

Lightweight Swift Dependency Injection Framework
Swift
1,784
star
29

assertj-android

A set of AssertJ helpers geared toward testing Android.
Java
1,577
star
30

haha

DEPRECATED Java library to automate the analysis of Android heap dumps.
Java
1,436
star
31

phrase

Phrase is an Android string resource templating library
Java
1,404
star
32

cane

Code quality threshold checking as part of your build
Ruby
1,325
star
33

anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.
Kotlin
1,310
star
34

seismic

Android device shake detection.
Java
1,275
star
35

sudo_pair

Plugin for sudo that requires another human to approve and monitor privileged sudo sessions
Rust
1,240
star
36

square.github.io

A simple, static portal which outlines our open source offerings.
CSS
1,153
star
37

spacecommander

Commit fully-formatted Objective-C as a team without even trying.
Objective-C
1,126
star
38

workflow

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Shell
1,124
star
39

workflow-kotlin

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Kotlin
1,027
star
40

certigo

A utility to examine and validate certificates in a variety of formats
Go
941
star
41

logcat

I CAN HAZ LOGZ?
Kotlin
895
star
42

radiography

Text-ray goggles for your Android UI.
Kotlin
852
star
43

whorlwind

Makes fingerprint encryption a breeze.
Java
817
star
44

dagger-intellij-plugin

An IntelliJ IDEA plugin for Dagger which provides insight into how injections and providers are used.
Java
796
star
45

cycler

Kotlin
791
star
46

Paralayout

Paralayout is a set of simple, useful, and straightforward utilities that enable pixel-perfect layout in iOS. Your designers will love you.
Swift
786
star
47

apropos

A simple way to serve up appropriate images for every visitor.
Ruby
764
star
48

shift

shift is an application that helps you run schema migrations on MySQL databases
Ruby
735
star
49

coordinators

Simple MVWhatever for Android
Java
702
star
50

subzero

Block's Bitcoin Cold Storage solution.
C
683
star
51

Blueprint

Declarative UI construction for iOS, written in Swift
Swift
672
star
52

shuttle

String extraction, translation and export tools for the 21st century. "Moving strings around so you don't have to"
Ruby
656
star
53

gifencoder

A pure Java library implementing the GIF89a specification. Suitable for use on Android.
Java
654
star
54

pollexor

Java client for the Thumbor image service which allows you to build URIs in an expressive fashion using a fluent API.
Java
633
star
55

intro-to-d3

a D3.js tutorial
CSS
602
star
56

kochiku

Shard your builds for fun and profit
Ruby
599
star
57

curtains

Lift the curtain on Android Windows!
Kotlin
570
star
58

RxIdler

An IdlingResource for Espresso which wraps an RxJava Scheduler.
Java
511
star
59

burst

A unit testing library for varying test data.
Java
464
star
60

field-kit

FieldKit lets you take control of your text fields.
JavaScript
463
star
61

SuperDelegate

SuperDelegate provides a clean application delegate interface and protects you from bugs in the application lifecycle
Swift
454
star
62

otto-intellij-plugin

An IntelliJ IDEA plugin to navigate between events posted by Otto.
Java
451
star
63

js-jose

JavaScript library to encrypt/decrypt data in JSON Web Encryption (JWE) format and to sign/verify data in JSON Web Signature (JWS) format. Leverages Browser's native WebCrypto API.
JavaScript
422
star
64

sharkey

Sharkey is a service for managing certificates for use by OpenSSH
Go
395
star
65

connect-api-examples

Code samples demonstrating the functionality of the Square Connect API
JavaScript
391
star
66

fdoc

Documentation format and verification
Ruby
380
star
67

ETL

Extract, Transform, and Load data with Ruby
Ruby
377
star
68

lgtm

Simple object validation for JavaScript.
JavaScript
370
star
69

papa

PAPA: Performance of Android Production Applications
Kotlin
345
star
70

laravel-hyrule

Object-oriented, composable, fluent API for writing validations in Laravel
PHP
341
star
71

in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
Objective-C
340
star
72

pylink

Python Library for device debugging/programming via J-Link
Python
331
star
73

workflow-swift

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Swift
326
star
74

pysurvival

Open source package for Survival Analysis modeling
HTML
319
star
75

rails-auth

Modular resource-based authentication and authorization for Rails/Rack
Ruby
291
star
76

cocoapods-generate

A CocoaPods plugin that allows you to easily generate a workspace from a podspec.
Ruby
279
star
77

inspect

inspect is a collection of metrics gathering, analysis utilities for various subsystems of linux, mysql and postgres.
Go
268
star
78

Aardvark

Aardvark is a library that makes it dead simple to create actionable bug reports.
Objective-C
260
star
79

gradle-dependencies-sorter

A CLI app and Gradle plugin to sort the dependencies in your Gradle build scripts
Kotlin
253
star
80

jetpack

jet.pack: package your JRuby rack app for Jetty.
Ruby
248
star
81

luhnybin

Shell
232
star
82

auto-value-redacted

An extension for Google's AutoValue that omits redacted fields from toString().
Java
211
star
83

protoparser

Java parser for .proto schema declarations.
Java
210
star
84

squalor

Go SQL utility library
Go
205
star
85

Listable

Declarative list views for iOS apps.
Swift
200
star
86

p2

Platypus Platform: Tools for Scalable Deployment
Go
196
star
87

mimecraft

Utility for creating RFC-compliant multipart and form-encoded HTTP request bodies.
Java
195
star
88

git-fastclone

git clone --recursive on steroids
Ruby
187
star
89

zapp

Continuous Integration for KIF
Objective-C
179
star
90

metrics

Metrics Query Engine
Go
170
star
91

ruby-rrule

RRULE expansion for Ruby
Ruby
170
star
92

quotaservice

The purpose of a quota service is to prevent cascading failures in micro-service environments. The service acts as a traffic cop, slowing down traffic where necessary to prevent overloading services. For this to work, remote procedure calls (RPCs) between services consult the quota service before making a call. The service isnโ€™t strictly for RPCs between services, and can even be used to apply quotas to database calls, for example.
Go
153
star
93

wire-gradle-plugin

A Gradle plugin for generating Java code for your protocol buffer definitions with Wire.
Groovy
153
star
94

goprotowrap

A package-at-a-time wrapper for protoc, for generating Go protobuf code.
Go
148
star
95

beancounter

Utility to audit the balance of Hierarchical Deterministic (HD) wallets. Supports multisig + segwit wallets.
Go
144
star
96

rce-agent

gRPC-based Remote Command Execution Agent
Go
136
star
97

womeng_handbook

Everything you need to start or expand a women in engineering group in your community.
129
star
98

cocoapods-check

A CocoaPods plugin that shows differences between locked and installed Pods
Ruby
126
star
99

point-of-sale-android-sdk

A simple library for letting Point of Sale take in-store payments for your app using Point of Sale API.
Java
119
star
100

in-app-payments-react-native-plugin

Objective-C
119
star