Git Product home page Git Product logo

loll's Introduction

loll 🀣

A fun(ctional) little frontend application framework. This is not production-ready. It's fun-ready.

Features:

  1. Async routing, useful for data fetching
  2. Fast VDOM-diffing via picodom
  3. Easy global state management
  4. Localized stateful components
  5. Tiny: 2.2kb gzipped with dependencies

Usage

The libraries herein can be used individually, or together for a fully fledged front-end application solution.

Why?

Some of the existing solutions are either too simple for the Real Worldβ„’, or have somewhat cumbersome APIs. I set out to create my ideal API, and here it is.

Essentially, I was lucky enough to find myself with some free time and thought it might be fun :)

License

Everything is MIT, with the exception of all dependendecies which are subject to their own licences. Find the dependencies for each library in their respective folders.

loll's People

Contributors

estrattonbailey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

loll's Issues

Cache existing node

Shouldn't need to query the DOM to find the root node. Should be able to use a prev reference and update after a fresh render.

Ensure re-render solution works

const app = require('./app.js')
const createStore = require('@loll/state')

const store = createStore({
  foo: false,
  bar: true
})

store.on('update', () => {
  app.go(window.location.pathname) // render existing route again
})

What if window.location contains query strings?

Component API: Mount, unmount, initialState

The component API could use mount and unmount, via on-load.

Is initialState() ok? Or should it just be an initial constructor? That's basically what it is, so maybe I'll call it init(). Could be considered a constructor for all intents and purposes, could even set state directly instead of returning state. Could also pry include a proxy of state so that you can't mutate it directly to begin with.

Components

So mount() and unmount() are much trickier than they would appear at first glance. I think that's the main barrier to having "components" as you would think about them in something like React.

As filed here, on-load correctly fires onunload when replaceChild(next, prev) is fired, because for a short period of time (I assume one tick, but a setTimeout(() => {}, 0) does not work) the DOM node is actually not present in the DOM. on-load is doing its job correctly. Since there is no reference to the node for a split second during that time, I'm having trouble finding a good way to tell if the node removal was in the act of morphing the DOM, or actually a valid unmounting, like from a route change.

Other issues

A good outline (from Choo) is here. It also references a few issues that I'll also need to ensure are addressed and tested and added to docs:

Additionally:

Other ideas

Questions

  1. On global state updates, they're currently morphing on a local level, and returning the morphed ref. How does this affect the top-level morph operation? Does it essentially morph twice (I don't think so) or does it result in the same node? (this should be what happens)
  2. How can I better utilize .isSameNode() or expose it for users?

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.