{"id":18095192,"url":"https://github.com/maxhallinan/zelektree","last_synced_at":"2025-04-13T09:34:33.824Z","repository":{"id":57405435,"uuid":"106266645","full_name":"maxhallinan/zelektree","owner":"maxhallinan","description":"Embed selectors in a Redux state tree.","archived":false,"fork":false,"pushed_at":"2017-10-18T11:48:37.000Z","size":32,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T01:06:19.326Z","etag":null,"topics":["redux","redux-state-tree","selector"],"latest_commit_sha":null,"homepage":"","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/maxhallinan.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-09T09:58:18.000Z","updated_at":"2019-03-03T10:57:54.000Z","dependencies_parsed_at":"2022-09-16T18:50:40.028Z","dependency_job_id":null,"html_url":"https://github.com/maxhallinan/zelektree","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhallinan%2Fzelektree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhallinan%2Fzelektree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhallinan%2Fzelektree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxhallinan%2Fzelektree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxhallinan","download_url":"https://codeload.github.com/maxhallinan/zelektree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248691223,"owners_count":21146304,"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":["redux","redux-state-tree","selector"],"created_at":"2024-10-31T19:09:26.147Z","updated_at":"2025-04-13T09:34:33.785Z","avatar_url":"https://github.com/maxhallinan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zelektree\n[![Build status](https://travis-ci.org/maxhallinan/zelektree.svg?branch=master)](https://travis-ci.org/maxhallinan/zelektree)\n[![Coverage Status](https://coveralls.io/repos/github/maxhallinan/zuhlektion/badge.svg?branch=master)](https://coveralls.io/github/maxhallinan/zuhlektion?branch=master)\n\nEmbed [selectors](https://stackoverflow.com/questions/38674200/what-are-selectors-in-redux)\nin a Redux state tree.\n\nThis is a convenient way for components to share selectors that are used widely\nthroughout an app.\n\nInspired by [Baobab](https://github.com/Yomguithereal/baobab#computed-data-or-monkey-business).\n\n\n## Install\n\n```\n$ yarn install zelektree\n```\n\n\n## Usage\n\n```javascript\nimport { connect, createStore, } from 'redux';\nimport { embedSelectors, } from 'zelektree';\n\nconst initialState = { foo: null, };\n\nconst reducer = (state = initialState) =\u003e state;\n\nconst store = createStore(\n  reducer,\n  // pass as the `enhancer` argument to `createStore`\n  embedSelectors({\n    // key each selector by intended state key name\n    isFoo: (state) =\u003e !!state.foo,\n  }),\n);\n\n// state and derived state are synced and merged\nconst state = store.getState(); // { foo: null, isFoo: false, }\n```\n\n\n## API\n\n### embedSelectors(selectors)\n\nTakes an object map of selectors and returns a Redux\n[StoreEnhancer](http://redux.js.org/docs/Glossary.html#store-enhancer).\n\nThe store enhancer refreshes the selectors each time `getState` is called and\nthe result is merged with the returned state.\n\n`embedSelectors` expects the top-level state value to be an object. To optimize\nperformance, this expectation is not enforced with runtime checks.\n\n#### selectors\n\nType: `{ [String]: (Object) -\u003e * }`\n\nAn object map of selectors. The key for each selector is used as the state tree\nkey for that selector's output. A selector is called with a single argument, `state`.\n`state` is the current state of the store.\n\n`embedSelectors` is interoperable with any selector that is soley a reduction of\nstate and not state and props, for example.\n\n\n## License\n\nMIT © [Max Hallinan](https://github.com/maxhallinan)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhallinan%2Fzelektree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxhallinan%2Fzelektree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxhallinan%2Fzelektree/lists"}