Releases: beforesemicolon/client-web-storage
Releases · beforesemicolon/client-web-storage
Release 1.7.1
New
Introducing AppState for global state management
Full Changelog: 1.7.0...1.7.1
Release 1.6.0
New
- introduces schema object literal for a more straightforward way to define the schema
- introduces
onandoffstore methods to listen(subscribe) to specific store events - introduces
interceptstore method to perform side effects before data is saved to the store on a specific event instead of all events likebeforeChangemethod PROCESSINGevent to track when the store is performing an action- the ability to override default keys used by the store as items identifiers and created and updated time
Improvements
- 100% test coverage
- Underneath code organization improved
- better error messages and capture mechanism
- documentation addresses more details and contains better examples
- better action interception data handling which allows for more things in the interception handler without compromising the data
Fixes
- In memory store is no longer a single global store for all items in the app. This issue would cause different stores to save data in the same place instead of being a separate thing
Breaking changes
- changes
MEMORY_STOREtoMEMORYSTOREfor naming consistency - default store type is now in-memory =>
MEMORYSTORE - Event
DELETEDrenamed toREMOVED sizeis no longer a property. It is aasyncfunction. This was because of a bug that was causing it to return inacurate results
What's Changed
- Bump json5 from 2.2.1 to 2.2.3 by @dependabot in #14
- simplify and improve store experience and coverage by @ECorreia45 in #15
New Contributors
- @dependabot made their first contribution in #14
Full Changelog: 1.5.0...1.6.0
Release 1.5.0
New
- custom types
ArrayOfandOneOffor schemas
const exampleSchema = new Schema<Prop>('example', {
id: new SchemaValue(OneOf(String, Number)), // define multiple type options for value
options: new SchemaValue(ArrayOf(String)), // specify what type of array it is
}, false)- Allow to override the data via
beforeChangereturn forCREATED,UPDATED, andLOADEDevents
const unsub = todoStore.beforeChange(async (eventType, data) => {
switch (eventType) {
case ClientStore.EventType.CREATED:
return await todoService.createTodo(data); // <- return the data
case ClientStore.EventType.UPDATED:
return await todoService.updateTodo(data.id, data); // <- return the data
case ClientStore.EventType.LOADED:
return await todoService.getAllByIds(data.map(m => m.id)); // <- return the data
default:
};
return true; // required to flag the store that the action should continue
});Fixes
LOADEDwas not broadcasted when the list provided was empty.- Schema was removing explicitly defined values which looked like default values when
includeDefaultKeyswas set to false - All classes where being set directly in window. Now they are available under
CWSobject on the client
What's Changed
- Develop by @ECorreia45 in #5
- #6 additional custom types by @ECorreia45 in #8
- #9 allow override via beforeChange by @ECorreia45 in #10
- #11 by @ECorreia45 in #12
Full Changelog: 1.4.5...1.5.0
Release Version 1.4.5
- Convert
loadItemsinto its own action so it does not keep triggeringcreateandupdateevents for every item on the list which can cause infinite loops between the api listener and the data creation;
Improvements:
- Calling
loadItemsno longer leave the store size at its previous state. The size of the store reflects the new items loaded; beforeChangeis now typed- Loaded items will now validate all items first before putting them into the store;
What's Changed
- Develop by @ECorreia45 in #1
- Develop by @ECorreia45 in #2
- Develop by @ECorreia45 in #3
- License by @ECorreia45 in #4
New Contributors
- @ECorreia45 made their first contribution in #1
Full Changelog: https://github.com/beforesemicolon/client-web-storage/commits/1.4.5
Release 1.3.0
Browser storage interface for IndexedDB, WebSQL, LocalStorage, and in-memory- data with basic Schema and data validation.
- Schema : Determines how the data looks like;
- SchemaValue : Creates a single value in the schema;
- ClientStore : Manages the data (CRUD);
// Define schema TS type
import {ClientStore, Schema} from "client-web-storage";
interface ToDo extends Schema.DefaultValue {
name: string;
description: string;
complete: boolean;
}
// create and define schema
const todoShema = new Schema<ToDo>("todo");
todoShema.defineField("name", String, {required: true});
todoShema.defineField("description", String);
todoShema.defineField("complete", Boolean);
// create and use the store
const todoStore = new ClientStore("todos", todoShema);
todoStore.createItem({
name: "Go to Gym" // only name is required
});
/* Creates item in the store
{
id: 3284732894792342, // generated id
name: "Go to Gym",
description: "",
complete: false,
createdDate: "January, 4th 2022",
lastUpdatedDate: "January, 4th 2022",
}
*/What's Changed
- Develop by @ECorreia45 in #1
Full Changelog: https://github.com/beforesemicolon/client-web-storage/commits/1.3.0