Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imanubhardwaj/vue-entity-adapter
Package to maintain entities in Vuex.
https://github.com/imanubhardwaj/vue-entity-adapter
flux state-management vue vue2 vuejs vuejs2 vuex vuex-orm-plugin vuex-plugin vuex-store vuex2 vuex3
Last synced: about 1 month ago
JSON representation
Package to maintain entities in Vuex.
- Host: GitHub
- URL: https://github.com/imanubhardwaj/vue-entity-adapter
- Owner: imanubhardwaj
- License: mit
- Created: 2019-08-28T17:50:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T08:22:55.000Z (about 2 years ago)
- Last Synced: 2024-11-25T02:21:06.078Z (about 2 months ago)
- Topics: flux, state-management, vue, vue2, vuejs, vuejs2, vuex, vuex-orm-plugin, vuex-plugin, vuex-store, vuex2, vuex3
- Language: JavaScript
- Homepage:
- Size: 4.77 MB
- Stars: 20
- Watchers: 2
- Forks: 3
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-state - vue-entity-adapter
README
# Note
This project is a fork of the project of [Manu Bhardwaj](https://github.com/imanubhardwaj),
You can access the original project [here](https://github.com/imanubhardwaj/vue-entity-adapter).The difference from this project to the original project, are just a few changes in the definitions for typescript and a small improvement in the ordering logic in the getAll method and in logic in addOne method.
# Introduction
Entity State adapter for managing record collections.
Entity provides an API to manipulate and query entity collections.
Reduces boilerplate for creating reducers that manage a collection of models.
Provides performant CRUD operations for managing entity collections.
Extensible type-safe adapters for selecting entity information.#### [Example](example)
## Installation
Installing with *npm*``npm i vue-entity-adapter-plus``
## Getting Started
* Create a ``EntityState``
``interface TodoState extends EntityState {}``
* Create an ``EntityAdapter``
``const todoAdapter = new EntityAdapter();``
## Adapter Methods
These methods are provided by the adapter object returned when using ``new EntityAdapter()``. The methods are used inside your mutations to manage the entity collection based on your provided actions.#### getInitialState
Returns the initialState for entity state based on the provided type. Additional state is also provided through the provided configuration object. The initialState is provided to your reducer function.## Entity Selectors
#### getOne
Returns the entity with the given id.#### getAll
Returns all entities from the state.#### getCount
Returns the number of entities from the state.#### getIds
Returns the ids of entities from the state.## Adapter Collection Methods
The entity adapter also provides methods for operations against an entity. These methods can change one to many records at a time. Each method returns the newly modified state if changes were made and the same state if no changes were made.
* addOne: Add one entity to the collection
* addMany: Add multiple entities to the collection
* addAll: Replace current collection with provided collection
* removeOne: Remove one entity from the collection
* removeMany: Remove multiple entities from the collection, by id or by predicate
* removeAll: Clear entity collection
* updateOne: Update one entity in the collection
* updateMany: Update multiple entities in the collection
* upsertOne: Add or Update one entity in the collection
* upsertMany: Add or Update multiple entities in the collection