import debounce from 'lodash/debounce';
export function getAgGridFilterNotifyModelFn(adaptableApi, colId, onModelChange) {
    const notifyModel = debounce(() => {
        const isActive = adaptableApi.filterApi.columnFilterApi.isColumnFilterActiveForColumn(colId);
        setTimeout(() => {
            // call it with non null to indicate that the filter is active
            // call it with null to indicate that the filter is not active
            // as per the AG Grid documentation
            // ref: also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case
            onModelChange(isActive ? true : null);
        }, 50);
    }, 50, {
        trailing: true,
    });
    return notifyModel;
}
