layrd

1.0.10 • Public • Published

Layrd is a tiny framework for composing vue3 "composables", but it has no dependencies on vue. Use Layrd when you want to compose a larger composable from many smaller ones.

// ./composables
const foo = (fooConfig, previousLayer, globalConfig) => {
  return { foo: 'foo' }
}

const bar = (barConfig, previousLayer, globalConfig) => {
  return {
    bar: 'bar',
    onInit: () => {
      /* If provided, this callback runs after the layrd object has been initialized. If an early layer need to sync state with later layers, initialize a watcher here. */
    }
  }
}

// ./inSomeOtherFile
const globalConfig = { name: 'myLayrdComposable' }

const fooConfig = {/* config object passed only to foo */}

const barConfig = {/* config object passed only to bar */}

const { foo, bar } = layrd(globalConfig)
  .layer(fooConfig)
  .layer(barConfig)
  .init(() => {
    /* This callback is run right before returning the entire layrd-object.
    May be used to set a semaphore "initialized" */
  })

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i layrd

    Weekly Downloads

    1

    Version

    1.0.10

    License

    Apache-2.0

    Unpacked Size

    15.7 kB

    Total Files

    5

    Last publish

    Collaborators

    • m3rtzi