{"id":21525892,"url":"https://github.com/briebug/smartish","last_synced_at":"2025-03-17T18:20:07.706Z","repository":{"id":47667697,"uuid":"354116734","full_name":"briebug/smartish","owner":"briebug","description":"Smartish is a small utility library that makes creating \"smartish\" components in Angular a breeze","archived":false,"fork":false,"pushed_at":"2021-08-18T21:29:09.000Z","size":416,"stargazers_count":2,"open_issues_count":5,"forks_count":1,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-01-24T05:29:17.922Z","etag":null,"topics":["angular","component-architecture","components","ngrx","state","state-machine","state-management","state-pattern","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/briebug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-02T19:40:53.000Z","updated_at":"2021-08-18T21:29:13.000Z","dependencies_parsed_at":"2022-08-21T12:40:25.386Z","dependency_job_id":null,"html_url":"https://github.com/briebug/smartish","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/briebug%2Fsmartish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fsmartish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fsmartish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briebug%2Fsmartish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briebug","download_url":"https://codeload.github.com/briebug/smartish/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244085009,"owners_count":20395523,"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":["angular","component-architecture","components","ngrx","state","state-machine","state-management","state-pattern","typescript"],"created_at":"2024-11-24T01:38:49.307Z","updated_at":"2025-03-17T18:20:07.661Z","avatar_url":"https://github.com/briebug.png","language":"TypeScript","readme":"# NgRx Smartish\n\nNgRx Smartish is a small utility library that makes creating \"smartish\" components in Angular a breeze. NgRx mixed with Smartish Components, provide a clean and declartive approach to building applications in Angular. \n\n\n## Getting Started\n\nYou can install the package using `npm install @briebug/ngrx-smartish`\n\nNext you will need to import `NgRxSmartishModule` in `app.module` as well as provide store using the `SMARTISH_STORE_TOKEN`.\n\n```\nimport { NgRxSmartishModule, SMARTISH_STORE_TOKEN } from '@briebug/ngrx-smartish';\nimoprt { StoreModule, Store } from '@ngrx/store';\n\n@NgModule({\n  imports: [\n      NgRxSmartishModule,\n      StoreModule.forRoot({...})\n  ],\n  providers: [{ provide: SMARTISH_STORE_TOKEN, useClass: Store }]\n})\nexport class AppModule {}\n```\n\n\n## SmartSelect\nWith SmartishNgRx you can reference NgRx Selectors directly in your Angular Component's template without the need to inject the `store`. You simple need to add the `MemoizedSelector` in your component class and reference that property with the `smartSelector` pipe in your template.\n\n```\nimport { selectError } from 'YOUR-STORE'\n\n@Component({\n    selector: 'app-error',\n    template: `\u003cp\u003e{{ selectError | smartSelect | async }}\u003c/p\u003e`\n})\nexport class ErrorComponent {\n    error = selectError;\n}\n```\n\n## SmartDispatch\n\nWith SmartishNgRx you can dispatch actions directly in your Angular Component's template without the need to dispatch an `@Output() EventEmitter` or injecting the `store`. You simply can use either the `smartDispatch` method.\n\n```\nimport { smartDispatch } from '@briebug/ngrx-smartish';\nimport { addTaco } from '...my-actions';\n\n@Component({\n    selector: 'app-component',\n    template: `\u003cbutton (click)=\"addTaco({ taco: form.value })\"\u003eAdd Taco\u003c/button\u003e\n})\nexport class MyComponent {\n    addTaco = smartDispatch(addTaco);\n}\n```\n\n## NgRxSmartishComponent\n\nWith SmartishNgRx you can reference your NgRx store directly in your Components classes (or templates) without providing the store in the constructor. It's as easy as having your component extends `SmartishNgRxComponent`. \n\n```\n@Component({\n    selector: 'app-tacos',\n    template: `\u003capp-taco *ngFor=\"let taco of (tacos$ | async)\" [taco]=\"taco\u003e\u003c/app-taco\u003e`\n})\nexport class TacosComponent extends SmartishNgRxComponent {\n    tacos$ = store.select(selectTacos);\n}\n```\n\n## Testing\nTesting with NgRxSmartish is made simple with the `NgRxSmartishTestingModule`. Just import `NgRxSmartishTestingModule` into your `TestBed` with the `forRoot()` static method. You can also pass an optional `MockStoreConfig` inside of `forRoot()` to save you from having to provide `provideMockStore(...)` in your tests. \n\n```\nconst config = { };\ndescribe('YourSmartishComponent', () =\u003e {\n  beforeEach(async () =\u003e {\n    imports: [NgRxSmartishTestingModule.forRoot({ initialState: {...}})],\n    declarations: [YourSmartishComponent]\n  });\n});\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriebug%2Fsmartish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriebug%2Fsmartish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriebug%2Fsmartish/lists"}