npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@asyncflowstate/svelte

v3.0.0

Published

Official Svelte bindings for AsyncFlowState. Reactive stores (createFlow, createFlowSequence, createFlowParallel) for managing async loading, error, and success states effortlessly.

Downloads

72

Readme

Installation

pnpm add @asyncflowstate/svelte @asyncflowstate/core

Quick Start

Basic Usage

<script>
  import { createFlow } from '@asyncflowstate/svelte';

  const flow = createFlow(async (id) => {
    const res = await fetch(`/api/users/${id}`);
    return res.json();
  }, {
    onSuccess: (user) => console.log('Fetched:', user.name),
  });
</script>

<button on:click={() => flow.execute('user-123')} disabled={$flow.loading}>
  {$flow.loading ? 'Loading...' : 'Fetch User'}
</button>

{#if $flow.data}
  <p>{$flow.data.name}</p>
{/if}

{#if $flow.error}
  <p class="error">Error: {$flow.error.message}</p>
{/if}

With Retry & Timeout

<script>
  import { createFlow } from '@asyncflowstate/svelte';

  const flow = createFlow(fetchData, {
    timeout: 5000,
    retry: { maxAttempts: 3, backoff: 'exponential' },
  });
</script>

Sequential Workflows

<script>
  import { createFlowSequence } from '@asyncflowstate/svelte';

  const sequence = createFlowSequence([
    { name: 'Validate', flow: validateFlow.flow },
    { name: 'Submit', flow: submitFlow.flow },
    { name: 'Notify', flow: notifyFlow.flow },
  ]);
</script>

<button on:click={() => sequence.execute()} disabled={$sequence.loading}>
  Run Workflow ({$sequence.progress}%)
</button>

Parallel Execution

<script>
  import { createFlowParallel } from '@asyncflowstate/svelte';

  const parallel = createFlowParallel(
    { users: usersFlow.flow, posts: postsFlow.flow },
    'allSettled'
  );
</script>

Keyed Lists (Delete Buttons)

<script>
  import { createFlowList } from '@asyncflowstate/svelte';

  const list = createFlowList(async (id) => api.deleteItem(id));
</script>

{#each items as item}
  <button on:click={() => list.execute(item.id, item.id)}
          disabled={$list.states[item.id]?.status === 'loading'}>
    Delete
  </button>
{/each}

New in v3.0

  • Flow DNA: Self-healing stores that adapt to execution patterns.
  • Ambient Intelligence: Svelte-native background predictive monitoring.
  • Speculative Execution: Low-latency interactions via intent prediction.
  • Emotional UX: Adaptive skeletons and transitions for Svelte transitions.
  • Collaborative Stores: Real-time state synchronization across devices.
  • Edge-First Logic: Native support for edge runtime optimizations.
  • Temporal Trace: History replay for Svelte reactive state.
  • Telemetry Dashboard: Live monitoring of all application flow stores.

Comprehensive Examples

1. The Power of Auto-Subscription

Svelte's $ syntax makes AsyncFlowState feels like a native part of the language.

<script>
  import { createFlow } from '@asyncflowstate/svelte';

  const flow = createFlow(api.saveData, {
    optimisticResult: (prev) => ({ ...prev, saved: true }),
    rollbackOnError: true
  });
</script>

<button on:click={() => flow.execute()} disabled={$flow.loading}>
  {$flow.loading ? 'Saving...' : 'Save Changes'}
</button>

{#if $flow.isSuccess}
  <p class="success">Data synced across devices!</p>
{/if}

2. AI-Powered: Flow DNA & Speculative Execution

Let the engine predict the next user move and pre-warm the state.

<script>
  const flow = createFlow(api.fetchDetails, {
    predictive: { prefetchOnHover: true }
  });
</script>

<div on:mouseenter={flow.prewarm} class="card">
  <button on:click={flow.execute}>
    {$flow.status === 'prewarmed' ? 'Instant View' : 'Load Details'}
  </button>
</div>

3. Enterprise Orchestration: createFlowSequence

Chain multiple stores with built-in progress tracking and failure recovery.

<script>
  import { createFlowSequence } from '@asyncflowstate/svelte';

  const sequence = createFlowSequence([
    { name: "Step 1", flow: flow1 },
    { name: "Step 2", flow: flow2 },
  ]);
</script>

<progress value={$sequence.progress} max="100" />
<button on:click={sequence.execute}>Run Sequence</button>

4. Real-Time Collaboration: Cross-Tab Mesh

Synchronize state across multiple browser tabs automatically.

<script>
  const flow = createFlow(api.updateTask, {
    crossTab: { sync: true, channel: 'tasks-mesh' }
  });
</script>

5. Multi-Keyed Flows: createFlowList

Perfect for lists where each item needs its own independent async state.

<script>
  import { createFlowList } from '@asyncflowstate/svelte';
  const list = createFlowList(api.deleteItem);
</script>

{#each items as item}
  <button on:click={() => list.execute(item.id)}
          disabled={$list.states[item.id]?.loading}>
    Delete {item.name}
  </button>
{/each}

New in v3.0

  • Flow DNA: Self-healing stores that adapt to execution patterns.
  • Ambient Intelligence: Svelte-native background predictive monitoring.
  • Speculative Execution: Low-latency interactions via intent prediction.
  • Emotional UX: Adaptive skeletons and transitions for Svelte transitions.
  • Collaborative Stores: Real-time state synchronization across devices.
  • Edge-First Logic: Native support for edge runtime optimizations.
  • Temporal Trace: History replay for Svelte reactive state.
  • Telemetry Dashboard: Live monitoring of all application flow stores.

API Reference

| Function | Description | | -------------------------------------- | ------------------------------------------------- | | createFlow(action, options?) | Core store for managing async actions | | createFlowSequence(steps) | Orchestrate sequential workflows | | createFlowParallel(flows, strategy?) | Run flows in parallel | | createFlowList(action, options?) | Manage multiple keyed flow instances | | createInfiniteFlow(action, options) | Manage paginated/infinite scrolling data fetching |

All stores implement the Svelte store contract — use $store for auto-subscription.

Cleanup

Call flow.destroy() when you need manual cleanup (e.g., in onDestroy):

<script>
  import { onDestroy } from 'svelte';

  const flow = createFlow(myAction);
  onDestroy(() => flow.destroy());
</script>

License

MIT © AsyncFlowState Contributors