{"id":25600610,"url":"https://github.com/aidanhibbard/olallie","last_synced_at":"2026-02-24T09:02:03.523Z","repository":{"id":211225546,"uuid":"728523914","full_name":"AidanHibbard/olallie","owner":"AidanHibbard","description":"Simple, type-safe, state management.","archived":false,"fork":false,"pushed_at":"2025-02-20T01:34:01.000Z","size":1044,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T12:11:56.484Z","etag":null,"topics":["actions","browser","getters","javascript","listeners","minimal","state","state-management","store","type-safe","typescript"],"latest_commit_sha":null,"homepage":"https://aidanhibbard.github.io/olallie/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AidanHibbard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/contributing.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["AidanHibbard"],"custom":["paypal.me/hibbardaidan"]}},"created_at":"2023-12-07T05:54:10.000Z","updated_at":"2025-02-20T01:34:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"4c79a5b4-b29a-4c17-9c61-63aa97b70547","html_url":"https://github.com/AidanHibbard/olallie","commit_stats":null,"previous_names":["aidanhibbard/olallie"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidanHibbard%2Folallie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidanHibbard%2Folallie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidanHibbard%2Folallie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidanHibbard%2Folallie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AidanHibbard","download_url":"https://codeload.github.com/AidanHibbard/olallie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248671637,"owners_count":21143138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","browser","getters","javascript","listeners","minimal","state","state-management","store","type-safe","typescript"],"created_at":"2025-02-21T15:27:08.154Z","updated_at":"2026-02-24T09:02:03.472Z","avatar_url":"https://github.com/AidanHibbard.png","language":"TypeScript","funding_links":["https://github.com/sponsors/AidanHibbard","paypal.me/hibbardaidan"],"categories":[],"sub_categories":[],"readme":"# Olallie\n\n![GitHub Actions Workflow Status](https://github.com/AidanHibbard/olallie/actions/workflows/spec.yml/badge.svg?branch=main)\n![NPM License](https://img.shields.io/npm/l/olallie)\n![NPM Downloads](https://img.shields.io/npm/dw/olallie)\n![NPM Version](https://img.shields.io/npm/v/olallie)\n![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/olallie)\n\n## Background\n\nBuilt to be a lightweight state management tool for framework-less projects.\n\nThe name Olallie comes from a [lake in Oregon.](https://www.fs.usda.gov/recarea/mthood/recarea/?recid=52978)\n\n## Quick links\n\n- [Installation](#installation)\n- [State](#state)\n- [Actions](#actions)\n- [Getters](#getters)\n- [Listeners](#listeners)\n- [Upgrade Guide](https://aidanhibbard.github.io/olallie/upgrade-guide.html)\n\n## Installation\n\n- Install the module\n\n  ```bash\n  npm i olallie\n  ```\n\n- Import `createStore`\n\n  ```ts\n  import createStore from 'olallie';\n  // or\n  const createStore = require('olallie');\n  ```\n\n## Example usage\n\n```ts\nimport createStore from 'olallie';\n// or\n// const createStore = require('olallie');\n\nconst store = createStore({\n  state: {\n    count: 0,\n  },\n  actions: {\n    add(value: number) {\n      // Actions have access to\n      // state, getters, and other actions\n      this.count += value;\n      return this.count;\n    },\n  },\n  getters: {\n    // State is automatically inferred\n    doubled: (state) =\u003e state.count * 2,\n  },\n});\n\n// Call options from the store\nstore.add(1); // 1\nconst count = store.count; // 1\nconst doubled = store.doubled; // 2\n```\n\n## Documentation\n\n### State\n\nState is always required when creating a new store, and should be an object.\n\n```ts\nconst stateStore = createStore({\n  state: {\n    count: 1,\n  },\n});\n```\n\nState values can be accessed from the store itself with type-safety.\n\n```ts\n// (property) count: number\nconst count = stateStore.count;\n```\n\nYou can also apply custom types to your state.\n\n```ts\ninterface State {\n  count: number;\n}\n\nconst stateStore = createStore({\n  state: {\n    count: 1,\n  } as State,\n});\n```\n\n### Actions\n\nActions should update, and, or return state values. They have access to state, getters, and other actions through `this`.\n\n```ts\nconst store = createStore({\n  state: {\n    count: 0,\n  },\n  actions: {\n    add(value: number) {\n      this.count += value;\n      return this.count;\n    },\n    double() {\n      this.count = this.doubled;\n      return this.count;\n    },\n    addAndDouble(value: number) {\n      this.add(value);\n      return this.double();\n    },\n  },\n  getters: {\n    doubled: (state) =\u003e state.count * 2,\n  },\n});\n```\n\nStore actions can also be async.\n\n```ts\nconst store = createStore({\n  state: {\n    response: undefined,\n  },\n  actions: {\n    async fetch(userId: string): Promise\u003cboolean\u003e {\n      let data;\n      await new Promise((resolve) =\u003e {\n        setTimeout(() =\u003e {\n          data = {\n            id: userId,\n            name: 'John Doe',\n          };\n          resolve(true);\n        }, 1);\n      });\n      this.response = data;\n    },\n  },\n});\n\nawait store.fetch('abcd');\nconst user = store.response;\n```\n\n### Getters\n\nGetters should return computed values without manipulating the state itself.\n\n```ts\nconst store = createStore({\n  state: {\n    firstName: 'John',\n    lastName: 'Doe'\n  },\n  getters: {\n    // State is automatically typed\n    /*\n    (parameter) state: {\n      firstName: string;\n      lastName: string;\n    }\n    */\n    fullName: (state) =\u003e `${state.firstName} ${state.lastName}`;\n  }\n});\n\nconst name = store.fullName; // \"John Doe\"\n```\n\n### Listeners\n\nListeners provide a helpful bit of reactivity with your store. They use the [Event Target API](https://developer.mozilla.org/en-US/docs/Web/API/Event/target) under the hood, and will dispatch a [Custom Event](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent) when a state value is changed.\n\nThe `listen()` method will provide a list of your stores state keys to choose from, and automatically infer the value for you.\n\n```ts\nconst store = createStore({\n  state: {\n    count: 0,\n  },\n});\n\n// (parameter) event: StoreEvent\u003cS, K\u003e\nconst listener = store.listen(\n  'count',\n  ({ detail, timeStamp }) =\u003e {\n    // Values are type-safe\n    /*\n  param (detail): {\n    value: number;\n    oldValue: number;\n  }\n  */\n    console.log('%j', {\n      newValue: detail.value,\n      oldValue: detail.oldValue,\n      timeStamp,\n    });\n  },\n  false,\n);\n\nstore.count++;\n```\n\nListeners can be removed by calling `unlisten()`.\n\n```ts\nlistener.unlisten();\n```\n\n## Contributing\n\nFollow the [contributor guidelines](.github/contributing.md) when opening a PR, or issue.\n\n### Project setup\n\n1. Install the version of node listed in the `.nvmrc`\n\n2. Install modules\n\n3. Run `spec` to lint \u0026 unit test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidanhibbard%2Folallie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidanhibbard%2Folallie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidanhibbard%2Folallie/lists"}