Created
March 10, 2018 06:52
-
-
Save hassantauqeer/d74cfb77b16fcbfc84e782e83e3c7be2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fromJS } from 'immutable'; | |
const initialState = fromJS({ | |
panes: [{ | |
title: 'abc', | |
service: '', | |
tagName: '', | |
preDefinedApi: '', | |
methodType: '', | |
url: '', | |
urlParams: [{ | |
label: '', | |
name: '', | |
value: '', | |
}], | |
headers: [{ | |
label: '', | |
name: '', | |
value: '', | |
}], | |
}], | |
activePane: '0' | |
}); | |
case ADD_PANE: | |
var obj = { | |
title: 'New Tab', | |
service: 'ser', | |
tagName: '', | |
preDefinedApi: '', | |
methodType: '', | |
url: '', | |
urlParams: [{ | |
label: '', | |
name: '', | |
value: '', | |
}], | |
headers: [{ | |
label: '', | |
name: '', | |
value: '', | |
}], | |
}; | |
return state.updateIn(['panes'], arr => arr.push(fromJS(obj)));//pushing an immutable object to an immutable array | |
case CHANGE_SERVICE: | |
var activePane = state.get('activePane');//getting index of nested object in Array(panes) that will be modified below... | |
return state.setIn(['panes', parseInt(activePane), 'service'], action.val); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment