Add ids() function to VMStore and destroy() method to VirtualMachine

This commit is contained in:
coolreader18
2019-01-30 12:33:32 -06:00
parent 13b2f83084
commit f064bcaf57

View File

@@ -40,6 +40,12 @@ impl VMStore {
cell.borrow_mut().remove(&id);
});
}
pub fn ids() -> Vec<JsValue> {
STORED_VMS.with(|cell| {
cell.borrow().keys().map(|k| k.into()).collect()
})
}
}
#[wasm_bindgen(js_name = VirtualMachine)]
@@ -64,5 +70,9 @@ impl WASMVirtualMachine {
}
}
fn destroy(self) {
VMStore::destroy(self.id)
}
// TODO: Add actually useful methods
}