Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hassantauqeer
Created March 10, 2018 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hassantauqeer/d74cfb77b16fcbfc84e782e83e3c7be2 to your computer and use it in GitHub Desktop.
Save hassantauqeer/d74cfb77b16fcbfc84e782e83e3c7be2 to your computer and use it in GitHub Desktop.
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