{"id":13793511,"url":"https://github.com/selfup/hyperapp-moisturize","last_synced_at":"2025-06-14T19:32:12.359Z","repository":{"id":57270120,"uuid":"116687604","full_name":"selfup/hyperapp-moisturize","owner":"selfup","description":"HOA for Dynamically upgrading Hyperapps (HMR/Dynamic Import/Whatever)","archived":false,"fork":false,"pushed_at":"2018-07-14T14:41:19.000Z","size":95,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-12T17:23:10.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codepen.io/selfup/pen/gooojE?editors=0010","language":"JavaScript","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/selfup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-08T14:34:54.000Z","updated_at":"2021-11-07T01:58:04.000Z","dependencies_parsed_at":"2022-09-02T03:31:41.223Z","dependency_job_id":null,"html_url":"https://github.com/selfup/hyperapp-moisturize","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/selfup/hyperapp-moisturize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfup%2Fhyperapp-moisturize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfup%2Fhyperapp-moisturize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfup%2Fhyperapp-moisturize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfup%2Fhyperapp-moisturize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selfup","download_url":"https://codeload.github.com/selfup/hyperapp-moisturize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfup%2Fhyperapp-moisturize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259657394,"owners_count":22891475,"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":[],"created_at":"2024-08-03T23:00:22.863Z","updated_at":"2025-06-14T19:32:12.102Z","avatar_url":"https://github.com/selfup.png","language":"JavaScript","funding_links":[],"categories":["Utilities V1"],"sub_categories":[],"readme":"_[Hyperapp](https://github.com/hyperapp/hyperapp) 1.0.1_\n\n# Moisturize your app today!\n\nDon't we all just love the word _moist_? :joy:\n\nApprently not, but we also cringe at dynamically _upgrading_ immutable stores.\n\nSo I present: `hyperapp-moisturize` :tada:\n\nAfter much deliberation on the Hyperapp repo itself ([Dynamic actions: How to add new actions at runtime? #533](https://github.com/hyperapp/hyperapp/issues/533)) we decided that a HOA (Higher Order App) was the way to go for Dynamically loading anything (focus on actions) into a Hyperapp.\n\n### Polyfills for Production\n\nPlease use a polyfill for `Object.assign` in production when using this package :pray:\n\nThe idea is that if you need to dynamically import, or if you are routing, you should already be using webpack or rollup/parcel (no dynamic import) for your app anyways :guitar:\n\n### Install\n\nCDN: \n```html\n\u003cscript src=\"https://unpkg.com/hyperapp-moisturize\"\u003e\u003c/script\u003e\n```\n\n```js\nconsole.log(hyperappMoisturize);\nconsole.log(window.hyperappMoisturize);\n```\n\nNode:\n```bash\nnpm install --save hyperapp-moisturize\n```\n\n### Purpose\n\nTo dynamically change the state / actions / root view of your app :smile:\n\nIf you read [this issue](https://github.com/hyperapp/hyperapp/issues/533) you will discover that there is more to this type of HOA than just dynamic actions :pray:\n\n[**Caveats**](https://github.com/hyperapp/hyperapp/issues/533#issuecomment-355764579)\n\nThis just means that for people building out dev tools like `hyperapp-logger` or `hyperapp-redux-devtools` need to know:\n\n\u003e we could have the dev tools look for typeof `payload.action === 'function' \u0026\u0026 payload.data` and then expand the payload so dynamic actions look normal\n\nNot a big deal :smile:\n\nI also add a property to the updated actions `.moisturizedOriginalName` for dev tools to look out for.\n\n_Eventually we will figure out a convention_ :joy:\n\n### How to use\n\n_Assuming you have dynamic imports already set up in your project_\n\n```js\nimport moisturize from 'hyperapp-moisturize';\n\nconst main = moisturize(app)(state, actions, view, document.body);\n\nimport('./thing.js')\n  .then(({ state: newState, actions: newActions, view: newView }) =\u003e {\n    main.updateApp({ newState, newActions, newView });\n  });\n```\n\nThat's it. Bam!\n\nYou don't have to pass all three options for it to work:\n\n```js\n// JUST ONE\n\nmain.updateApp({ newActions });\n\n// OR TWO\n\nmain.updateApp({ newState, newActions });\n\n// OR THREE\n\nmain.updateApp({ newState, newActions, newView })\n```\n\n### Example CodePen\n\nhttps://codepen.io/selfup/pen/gooojE?editors=0010\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfup%2Fhyperapp-moisturize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselfup%2Fhyperapp-moisturize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfup%2Fhyperapp-moisturize/lists"}