{"id":18634925,"url":"https://github.com/typeheim/fluent-states","last_synced_at":"2025-08-25T02:15:53.012Z","repository":{"id":57168573,"uuid":"455265700","full_name":"typeheim/fluent-states","owner":"typeheim","description":"Simple and clear states management for Angular apps","archived":false,"fork":false,"pushed_at":"2022-06-20T19:24:41.000Z","size":685,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-27T00:41:56.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/typeheim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-02-03T17:39:56.000Z","updated_at":"2022-02-04T08:24:40.000Z","dependencies_parsed_at":"2022-09-02T09:20:15.717Z","dependency_job_id":null,"html_url":"https://github.com/typeheim/fluent-states","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/typeheim%2Ffluent-states","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeheim%2Ffluent-states/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeheim%2Ffluent-states/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeheim%2Ffluent-states/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typeheim","download_url":"https://codeload.github.com/typeheim/fluent-states/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239433910,"owners_count":19637806,"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-11-07T05:22:31.178Z","updated_at":"2025-02-18T08:13:51.696Z","avatar_url":"https://github.com/typeheim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FluentStates\n\nEasy and clear state management for Angular apps.\n\n# Getting Started\n\nInstall package\n\n```shell\nyarn add @typeheim/fire-rx\nyarn add @typeheim/fluent-states\n//or\nnpm install @typeheim/fluent-states\nnpm install @typeheim/fire-rx\n```\n\n# Overview\n\nKey components of FluentStates are StateModel and StreamStore. StreamStore define store of a state and then StateModel\ncontrol all of the read and write access to the state.\n\n## Working with state model\n\n### Defining store model\n\nFirst of all, you need to define store. Store is a calls that consist of observables that contain data. All of the state\nobservables must be public but you can have private/protected observables as well to create any pipes.\n\n```typescript\nimport {StreamStore} from '@typeheim/fluent-states'\nimport {StatefulSubject, ValueSubject} from '@typeheim/fire-rx'\nimport {map, Subject} from 'rxjs'\n\nexport class BookStore extends StreamStore {\n  private securityArchive = new ValueSubject([])\n\n  public shelfStream = new StatefulSubject()\n\n  public archiveStream = new ValueSubject([])\n\n  public visitorsStream = new Subject()\n\n  public securityArchiveIdentifiersStream = this.securityArchive.pipe(map(item =\u003e item.id))\n}\n\n// define state type to use in type definitions further on\nexport type BookState = State\u003cBookStore\u003e\n```\n\nOnce you defined store, you can get readonly state that consist of all of the public properties.\n\n```typescript\nconst store = new BookStore()\nconst state = store.getState()\n```\n\n### Defining state model\n\nOnce you defined store, you can define state model by extending it from StateModel and implementing `store` property.\nThen you can define any methods to manipulate state through store.\n\n```typescript\nimport {StateModel} from '@typeheim/fluent-states'\n\nexport class BookStateModel\u003cBookStore\u003e extends StateModel {\n  protected store = new BookStore()\n\n  public addBooks(boooks) {\n    this.store.shelfStream.next(books)\n  }\n\n  public mooveBooksToArchive(boooks) {\n    this.store.archiveStream.next(books)\n  }\n}\n```\n\nState model provide access to readonly state through readonly property `state`.\n\n```typescript\nconst bookStateModel = new BookStateModel()\nconst bookState = stateModel.state\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeheim%2Ffluent-states","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypeheim%2Ffluent-states","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeheim%2Ffluent-states/lists"}