File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,26 +23,25 @@ const styles = {
2323 ` ,
2424} ;
2525
26+ const testData = {
27+ spectra : [
28+ {
29+ source : {
30+ jcampURL :
31+ 'https://cheminfo.github.io/nmr-dataset-demo/cytisine/13c.jdx' ,
32+ } ,
33+ } ,
34+ ] ,
35+ } ;
36+
2637export default function NMRiumWrapper ( ) {
2738 const [ data , setDate ] = useState < NMRiumData > ( ) ;
2839
2940 const actionHandler = useActions ( ) ;
3041
3142 useEffect ( ( ) => {
32- events . on ( 'load' , ( result ) => {
33- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34- const spectra : any [ ] = [ ] ;
35- // eslint-disable-next-line no-restricted-syntax
36- for ( const jcampURL of result . urls ) {
37- spectra . push ( {
38- source : {
39- jcampURL,
40- } ,
41- } ) ;
42- }
43- setDate ( {
44- spectra,
45- } ) ;
43+ events . on ( 'load' , ( _data ) => {
44+ setDate ( _data ) ;
4645 } ) ;
4746 } ) ;
4847
@@ -51,11 +50,7 @@ export default function NMRiumWrapper() {
5150 < div css = { styles . header } >
5251 < Button . Done
5352 onClick = { ( ) => {
54- events . trigger ( 'load' , {
55- urls : [
56- 'https://cheminfo.github.io/nmr-dataset-demo/cytisine/13c.jdx' ,
57- ] ,
58- } ) ;
53+ events . trigger ( 'load' , testData ) ;
5954 } }
6055 >
6156 Test Load from external URL
Original file line number Diff line number Diff line change 1+ import { NMRiumData } from 'nmrium' ;
2+
13type Actions = 'load' | 'test' ;
24
3- interface LoadSpectra {
4- urls : string [ ] ;
5- }
65interface TestData {
76 testData : string ;
87}
98
109type EventData < T extends Actions > = T extends 'load'
11- ? LoadSpectra
10+ ? NMRiumData
1211 : T extends 'test'
1312 ? TestData
1413 : never ;
You can’t perform that action at this time.
0 commit comments