Guest User

Untitled

a guest
Nov 14th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. export default (state = {}, action) => {
  2. switch(action.type) {
  3. case 'addConnection':
  4. return {
  5. connections: {
  6. ...state.connections, {
  7. action.compositeKey: action.connection
  8. }
  9. }
  10.  
  11. default:
  12. return state
  13. }
  14. }
  15.  
  16. const reducer = (state = {}, action) => {
  17. switch (action.type) {
  18. case 'addConnection':
  19. return Object.assign({}, state, {
  20. connections: [
  21. ...state.connections,
  22. {
  23. [actions.compositeKey]: action.connection
  24. }
  25. ]
  26. });
  27. default:
  28. return state;
  29. }
  30. }
  31.  
  32. export default reducer;
  33.  
  34. const reducer = (state = {}, {type, compositeKey, connection}) => {
  35. switch (type) {
  36. case 'addConnection':
  37. return Object.assign({}, state, {
  38. connections: state.connections.concat({
  39. [compositeKey]: connection
  40. })
  41. });
  42. default:
  43. return state;
  44. }
  45. }
  46.  
  47. export default reducer;
  48.  
  49. import Immutable from 'immutable';
  50.  
  51. const reducer = (state = Immutable.Map(), {type, compositeKey, connection}) => {
  52. switch (type) {
  53. case 'addConnection':
  54. return state.set(
  55. 'connections',
  56. state.get('connections').concat({
  57. [compositeKey]: connection
  58. })
  59. );
  60. default:
  61. return state;
  62. }
  63. }
  64.  
  65. export default reducer;
  66.  
  67. const reducer = (state = {}, {type, compositeKey, connection}) => {
  68. switch (type) {
  69. case 'addConnection':
  70. var newData={};
  71. newData[compositeKey]=connection;
  72. return Object.assign({}, state, newData)
  73. });
  74. default:
  75. return state;
  76. }
  77. }
  78.  
  79. export default reducer;
Add Comment
Please, Sign In to add comment