Rocket Logo Stoxy Docs Guides Toggle darkmode

Methods: Remove

Remove object(s) from a state object using a predicate.

Allows for removing one of multiple objects from the state object without having to read the object data manually.


keyKey in string form. Used as the name of the state object
predicateThe Predicate by which the objects are removed


A promise which resolves to the write result of the object: {key: string, value: any}


import { remove } from '@stoxy/core';

// Removes product with the id 1
remove("shoppingcart", product => === 1);

import { remove } from '@stoxy/core';

// Remove all products with a price over 5
remove("shoppingcart", product => product.price > 5);

import { remove } from '@stoxy/core';

// Remove all meat
remove("shoppingcart", removeMeat);

function removeMeat(product) {
    if (product.type === "Meat" || product.type === "Chicken") {
        return true;
    return false;