{"id":21026128,"url":"https://github.com/burntcaramel/awareness","last_synced_at":"2025-08-24T21:09:27.733Z","repository":{"id":86335880,"uuid":"109983435","full_name":"BurntCaramel/awareness","owner":"BurntCaramel","description":"Bring components to life with loaded data, animation, and multi-step asynchronous actions","archived":false,"fork":false,"pushed_at":"2017-12-24T01:39:04.000Z","size":12,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T14:32:40.954Z","etag":null,"topics":["actions","async","es6","generators","javascript"],"latest_commit_sha":null,"homepage":"https://awareness.collected.design/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BurntCaramel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"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}},"created_at":"2017-11-08T14:03:36.000Z","updated_at":"2019-10-08T18:45:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"b0b9e7f8-1528-4283-af5e-84d25559667b","html_url":"https://github.com/BurntCaramel/awareness","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntCaramel%2Fawareness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntCaramel%2Fawareness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntCaramel%2Fawareness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntCaramel%2Fawareness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BurntCaramel","download_url":"https://codeload.github.com/BurntCaramel/awareness/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243462551,"owners_count":20294949,"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","async","es6","generators","javascript"],"created_at":"2024-11-19T11:42:19.122Z","updated_at":"2025-03-13T18:42:27.978Z","avatar_url":"https://github.com/BurntCaramel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# awareness\n\n[![Travis][build-badge]][build]\n[![npm package][npm-badge]][npm]\n[![Coveralls][coveralls-badge]][coveralls]\n\n\n## Overview\n\n- Easily create rich actions\n- Use generator functions for animation\n- Use async functions\n- Transform existing state just like React’s functional `setState((prevState) =\u003e newState)`\n\n\n## Libraries\n\n- [React library](https://github.com/RoyalIcing/react-organism)\n- [Preact library](https://github.com/RoyalIcing/preact-organism)\n- [Redux library](https://github.com/RoyalIcing/redux-organism)\n\n\n## Handler types\n\n### Function returning new state\n\n```js\nconst changeCarrots = () =\u003e ({\n  carrots: 25\n})\n```\n\n### Function returning function that transforms old state to new state\n\n```js\nconst addCarrots = () =\u003e ({ carrots }) =\u003e ({\n  carrots: carrots + 10\n})\n```\n\n### Async function returning new state\n\n```js\nconst changeCarrotsInFuture = async () =\u003e {\n  const res = await fetch('/api/carrots')\n  const data = res.json()\n  return { carrots: data.carrots }\n}\n```\n\nOr with `Promise`:\n\n```js\nconst changeCarrotsInFuture = () =\u003e {\n  return fetch('/api/carrots')\n    .then(res =\u003e res.json())\n    .then(data =\u003e ({ carrots: data.carrots }))\n  })\n}\n```\n\n### Generator function yielding new state\n\n```js\n// Will update state on each frame: 0, 1, 2, 3, 4, 5\nfunction * animateCarrotsZeroToFive() {\n  yield { carrots: 0 }\n  yield { carrots: 1 }\n  yield { carrots: 2 }\n  yield { carrots: 3 }\n  yield { carrots: 4 }\n  yield { carrots: 5 }\n}\n```\n\n### Generator function yielding function that transforms old state to new state\n\n```js\n// Will update state for 10 frames: carrots+1, carrots+2, … carrots+9, carrots+10\nfunction * animateCarrotsByTen() {\n  let total = 10\n  while (total \u003e 0) {\n    yield ({ carrots }) =\u003e { carrots: carrots + 1 }\n    total -= 1\n  }\n}\n```\n\n### Generator function yielding Promise resolving to new state\n\n```js\n// Will use result of fetching `url` and store it in state\nfunction * loadURL(url) {\n  yield { loading: true }\n  yield fetch(url).then(res =\u003e res.json())\n  yield { loading: false }\n}\n```\n\n\n[build-badge]: https://img.shields.io/travis/RoyalIcing/awareness/master.png?style=flat-square\n[build]: https://travis-ci.org/RoyalIcing/awareness\n\n[npm-badge]: https://img.shields.io/npm/v/awareness.png?style=flat-square\n[npm]: https://www.npmjs.org/package/awareness\n\n[coveralls-badge]: https://img.shields.io/coveralls/RoyalIcing/awareness/master.png?style=flat-square\n[coveralls]: https://coveralls.io/github/RoyalIcing/awareness\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburntcaramel%2Fawareness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburntcaramel%2Fawareness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburntcaramel%2Fawareness/lists"}