-
Couldn't load subscription status.
- Fork 4
3. Wrapper Events
Chandu Nainala edited this page Mar 23, 2023
·
1 revision
NMRium wrapper uses a custom event to handle the communication between NMRium and the parent application, for that we create MessageEvents by using a window interface. We provide two events helper functions in /src/events/event.ts, which you can use by importing events.
import events from '../events';
events.trigger(eventName, data);
events.on(eventName, listenerHandler);| name | data/handler | description |
|---|---|---|
| load | LoadData Object | load spectra and molecules |
| error | (error:Error)=>ErrorHanlder | triggered once error happen at level of the wrapper |
| dataChange | (data:NMRiumData)=>{} | triggered when changes happen on the side of NMRium |
| actionRequest | ActionRequest Object | export spectra viewer as blob |
| actionResponse | ActionResponse Object | export spectra viewer as blob |
import events from '../events';
events.trigger('load', {
data: [File1,File2,....etc],
type:"file"
}
); import events from '../events';
events.trigger('load', {
data: [
'https://cheminfo.github.io/nmr-dataset-demo/cytisine/13c.jdx',
'https://cheminfo.github.io/bruker-data-test/data/zipped/aspirin-1h.zip',
...etc
],
type:"url"
}
);You can pass NMRium data that you get when you export the data from the NMRium or what you received from dataChange event
events.trigger('load', {
data: {
spectra:[
source:{
jcampURL:""
}
]
},
type:"nmrium"
}
);events.on('error', (error)=>{
// you code here
});events.on('dataChange', (data)=>{
// you code here
});