@@ -94,7 +94,7 @@ events.on(eventName, listenerHandler);
9494| actionRequest | ActionRequest Object | export spectra viewer as blob |
9595| actionResponse | ActionResponse Object | export spectra viewer as blob |
9696
97- #### Load spectra and molfile files:
97+ #### Load spectra and molfile files example :
9898``` ts
9999 import events from ' ../events' ;
100100
@@ -145,7 +145,7 @@ events.on('error', (error)=>{
145145});
146146```
147147
148- #### Data change hander example:
148+ #### Data change handler example:
149149
150150``` ts
151151events .on (' dataChange' , (data )=> {
@@ -176,100 +176,3 @@ Here you can find the links to NMRium and all the repositories we are aware of w
176176- [ NMRium] ( https://www.nmrium.org/ )
177177- [ nmrXiv] ( https://nmrxiv.org/ )
178178- [ Chemotion] ( https://www.chemotion.net/ )
179- =======
180- ``` docker run -it --rm -p 1337:80 nmrium-rw:prod ```
181-
182- ### Wrapper Events
183-
184- NMRium wrapper uses a custom event to handle the communication between NMRium and the parent application, for that we create multiple events:
185-
186- #### Events in action
187- you can use the events helper functions or create message events manually.
188-
189- 1 . Helper function
190-
191- ``` ts
192- import events from ' ../events' ;
193-
194- events .trigger (eventName , data );
195-
196- events .on (eventName , listenerHandler );
197-
198- ```
199-
200- 2 . Message event
201-
202- ``` ts
203- window .postMessage ({ type: ` nmr-wrapper:${eventName } ` , data }, ' *' );
204-
205- window .addEventListener (` message ` , listenerHandler )
206- ```
207-
208- #### Events
209-
210- | name | data/handler | description |
211- | :---- | ------------------- | :---- |
212- | load | LoadData Object | load spectra and molecules |
213- | error | (error: Error )=>ErrorHanlder | triggered once error happen at level of the wrapper |
214- | dataChange | (data: NMRiumData )=>{} | triggered when changes happen on the side of NMRIum |
215-
216-
217-
218- #### Load spectra and molfile files:
219- ``` ts
220- import events from ' ../events' ;
221-
222- events .trigger (' load' , {
223- data: [File1 ,File2 ,... .etc ],
224- type:" file"
225- }
226- );
227- ```
228-
229- #### Load spectra and molfile from external URLs example:
230- ``` ts
231- import events from ' ../events' ;
232-
233- events .trigger (' load' , {
234- data: [
235- ' https://cheminfo.github.io/nmr-dataset-demo/cytisine/13c.jdx' ,
236- ' https://cheminfo.github.io/bruker-data-test/data/zipped/aspirin-1h.zip' ,
237- ... etc
238- ],
239- type:" url"
240- }
241- );
242- ```
243-
244- #### Load NMRium data example:
245-
246- You can pass NMRium data that you get when you export the data from the NMRium or what you received from dataChange event
247- ``` ts
248- events .trigger (' load' , {
249- data: {
250- spectra:[
251- source :{
252- jcampURL:" "
253- }
254- ]
255- },
256- type:" nmrium"
257- }
258- );
259- ```
260-
261- #### Error handler example:
262-
263- ``` ts
264- events .on (' error' , (error )=> {
265- // you code here
266- });
267- ```
268-
269- #### Data change hander example:
270-
271- ``` ts
272- events .on (' dataChange' , (data )=> {
273- // you code here
274- });
275- ```
0 commit comments