package ru.dbotthepony.mc.otm.storage

fun <T : StorageStack<T>> IStorageProvider<T>.removeListenerAndNotify(listener: IStorageEventConsumer<T>): Boolean {
	if (removeListener(listener)) {
		for (stack in stacks) {
			listener.onStackRemoved(stack.id)
		}

		return true
	}

	return false
}

fun <T : StorageStack<T>> IStorageProvider<T>.addListenerAndNotify(listener: IStorageEventConsumer<T>): Boolean {
	if (addListener(listener)) {
		for (stack in stacks) {
			listener.onStackAdded(stack.stack, stack.id, this)
		}

		return true
	}

	return false
}
