Giter Club home page Giter Club logo

sveltekit-eventsourced-funnel's Introduction

sveltekit-eventsourced-funnel

Node.js CI codecov

Example of building a SvelteKit project with event sourcing.

Demonstrates:

  1. POJOs for event sourced models
  2. Repository pattern for persistence via local storage

As with Redux, the logic is external to the components. You can easily hook into every event for analytics and more. See unit test of the "Funnel model" to see that the logic can be tested independently of the UI.

Includes Tailwind with JIT compiler for easy copy and pasting of UIs from Tails, TailwindUI, Shuffle, or etc.

Quick Walkthrough

This project is a marketing and sales funnel - a simple series of web pages where the user can make a choice to proceed deeper into the funnel or not. Each step in the funnel is simply a route, in the src/routes directory. In src/lib/steps.js we create a linked-list like array of step "Value Objects". Index is the starting page.

The whole application is a Funnel, and thus we have a Funnel model in src/lib/models/Funnel.js - this is where the bulk of the logic resides.

There will only be one instance of a Funnel per browser session. To get that instance, the file src/lib/funnel.js provides a load function that will create a new funnel instance and initialize it with steps, or, if an instance already exists, load the existing one.

Each page loads the funnel instance onMount, which is client side only. The user performs some sort of action, which is a method call on the funnel object, and then, using the funnelRepository, the change is persisted to local storage via commit.

Once commits are successful, enqueued events fire, and we can navigate the user to their next step.

Project bootstrapped with create-svelte.

Further Reading

sourced has been around for several years for building event sourced models for backend services. This means with sourced you can build your "model" microservices in the same way you build your front end models.

sveltekit-eventsourced-funnel's People

Contributors

patrickleet avatar renovate-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.