Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NRayya authored Jan 2, 2023
1 parent 36095f0 commit 15157e3
Showing 1 changed file with 2 additions and 99 deletions.
101 changes: 2 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ events.on(eventName, listenerHandler);
| actionRequest | ActionRequest Object | export spectra viewer as blob |
| actionResponse | ActionResponse Object | export spectra viewer as blob |

#### Load spectra and molfile files:
#### Load spectra and molfile files example:
```ts
import events from '../events';

Expand Down Expand Up @@ -145,7 +145,7 @@ events.on('error', (error)=>{
});
```

#### Data change hander example:
#### Data change handler example:

```ts
events.on('dataChange', (data)=>{
Expand Down Expand Up @@ -176,100 +176,3 @@ Here you can find the links to NMRium and all the repositories we are aware of w
- [NMRium](https://www.nmrium.org/)
- [nmrXiv](https://nmrxiv.org/)
- [Chemotion](https://www.chemotion.net/)
=======
```docker run -it --rm -p 1337:80 nmrium-rw:prod```

### Wrapper Events

NMRium wrapper uses a custom event to handle the communication between NMRium and the parent application, for that we create multiple events:

#### Events in action
you can use the events helper functions or create message events manually.

1. Helper function

```ts
import events from '../events';

events.trigger(eventName, data);

events.on(eventName, listenerHandler);

```

2. Message event

```ts
window.postMessage({ type: `nmr-wrapper:${eventName}`, data }, '*');

window.addEventListener(`message`, listenerHandler)
```

#### Events

| 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 |



#### Load spectra and molfile files:
```ts
import events from '../events';

events.trigger('load', {
data: [File1,File2,....etc],
type:"file"
}
);
```

#### Load spectra and molfile from external URLs example:
```ts
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"
}
);
```

#### Load NMRium data example:

You can pass NMRium data that you get when you export the data from the NMRium or what you received from dataChange event
```ts
events.trigger('load', {
data: {
spectra:[
source:{
jcampURL:""
}
]
},
type:"nmrium"
}
);
```

#### Error handler example:

```ts
events.on('error', (error)=>{
// you code here
});
```

#### Data change hander example:

```ts
events.on('dataChange', (data)=>{
// you code here
});
```

0 comments on commit 15157e3

Please sign in to comment.