Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
co-browser-storage
Advanced tools
Manage browser storage variables in a convenient way using Angular 2 and @ngrx/store.
npm install
npm run build
npm start
npm install --save co-browser-storage
Create browser storage config file my-browser-storage-config.ts
where you specify all your browser storage variables.
export const NAMESPACE = 'myBrowserStore'
export const DEBUG_MODE = 'debugMode'
export const myBrowserStorageConfig = {
namespace: NAMESPACE,
initialState: [
// List storage variables here
{
key: DEBUG_MODE,
value: 'true',
storageType: 'localStorage',
valueType: 'text'
}
]
}
Initialize the store and provide the model
import {provideStore} from '@ngrx/store'
import {cbsReducer} from 'co-browser-storage/co-browser-storage'
import {
initialzeCbs,
getInitialCbsState,
CbsModel
} from 'co-browser-storage/co-browser-storage'
import {myBrowserStorageConfig} from './my-browser-storage-config'
initializeCbs(myBrowserStorageConfig)
bootstrap(AppCmp, [
CbsModel,
provideStore({
cbsReducer
}, {
cbsReducer: getInitialCbsState()
})
])
Using the GUI component for managing browser storage variables
import {CbsCmp} from 'co-browser-storage/co-browser-storage'
@Component({
directives: [CbsCmp],
template: `
<cbs-cmp></cbs-cmp>
`
})
export class AppComponent {}
Only show selected items in GUI
<cbs-cmp [itemsToShow]="['debugMode', 'otherItem']"></cbs-cmp>
import {CbsModel} from 'co-browser-storage/co-browser-storage'
...
let debugMode$ = cbsModel.getItemByKey('debugMode')
Or using store directly
import {Store} from '@ngrx/store'
...
let cbsReducer$ = store.select('cbsReducer')
let debugMode$ = cbsReducer$.map(cbs => cbs.find(i => i.key === 'debugMode'))
import {CbsModel} from 'co-browser-storage/co-browser-storage'
...
cbsModel.updateItem({
key: 'debugMode',
value: 'false'
})
// Multiple at once
cbsModel.updateItems([
{
key: 'debugMode',
value: 'false'
},
{
key: 'otherItem',
value: 'otherValue'
}
])
import {CbsModel} from 'co-browser-storage/co-browser-storage'
...
// cbsModel.truthy takes a string or an array of strings
let isDebugMode$ = cbsModel.truthy('debugMode')
FAQs
Browser storage mangement for Angular 2 using ngrx/store
The npm package co-browser-storage receives a total of 3 weekly downloads. As such, co-browser-storage popularity was classified as not popular.
We found that co-browser-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.