Skip to main content

Type Alias: InsertProductAtSnap

InsertProductAtSnap = (target, expectedProductId) => Promise<boolean>

Inserts the chosen product at a joint between two placed modular items. Use an available insert control and its product ID from modular.snapPlacementControls. Returns true when the insert commits and false if the choice, joint or placement is stale or invalid. Use the add-to-snap action for an open joint.

Parameters​

target​

PlacedSnapTarget

expectedProductId​

string

Returns​

Promise<boolean>

Example​

const { actions, observers } = window.mimeeqApp;
const placement = observers.modular.snapPlacementControls.getValue();
const control = placement?.controls.find(({ type, availability }) =>
type === 'insert' && availability === 'available',
);
if (placement && control) {
const inserted = await actions.insertProductAtSnap(control.target, placement.productId);
console.log(inserted);
}