immutable.js

Immutable, update inside map not returning correct object

喜你入骨 提交于 2020-01-17 05:09:12
问题 I am trying to write a function to update an immutable object I have. I am using return myitem.updateIn so i can chain another update ontop of this one that is already working. So far, I have this : memo.updateIn(['Topics', 'filters'], function(topic) { topic.map(function(singleTopic) { singleTopic.update('filters', function(subTopicFilters) { subTopicFilters.map(function(singleSubTopic) { if(singleSubTopic.get('checked')){ console.log("check", singleTopic.toJS()); return singleTopic.set(

Immutable, why does my nested object using fromJS are not immutable when I use reselect

我们两清 提交于 2020-01-17 03:19:08
问题 I have a bug with immutablejs and reselect. I have the following redux store in my reactjs application : /* * The reducer takes care of our data * Using actions, we can change our application state * To add a new action, add it to the switch statement in the homeReducer function * * Example: * case YOUR_ACTION_CONSTANT: * return assign({}, state, { * stateVariable: action.var * }); */ import { fromJS } from 'immutable'; import { CHANGE_FORM, SENDING_REQUEST, REQUEST_SUCCESS, CLEAR_SUCCESS,

Immutable.js Map with numeric key (performance test included)

不羁岁月 提交于 2020-01-13 10:05:30
问题 I'm using Immutable.js with Redux in my React Native app. Metadata, such as lookup tables, are fetched from a server and persisted locally in the app as Immutable.Map. The keys for the lookup values are integers (the primary key in the db). When I fetch the data all integer keys are coerced into strings. This is normal behaviour for js objects. Thus, when a lookup Map is created, the keys will be strings. Example: let colors = Immutable.Map({ '10': 'yellow', '20': 'pink', .. }) The objects

Immutable.js Map with numeric key (performance test included)

隐身守侯 提交于 2020-01-13 10:05:13
问题 I'm using Immutable.js with Redux in my React Native app. Metadata, such as lookup tables, are fetched from a server and persisted locally in the app as Immutable.Map. The keys for the lookup values are integers (the primary key in the db). When I fetch the data all integer keys are coerced into strings. This is normal behaviour for js objects. Thus, when a lookup Map is created, the keys will be strings. Example: let colors = Immutable.Map({ '10': 'yellow', '20': 'pink', .. }) The objects

Immutable.js Map with numeric key (performance test included)

被刻印的时光 ゝ 提交于 2020-01-13 10:05:04
问题 I'm using Immutable.js with Redux in my React Native app. Metadata, such as lookup tables, are fetched from a server and persisted locally in the app as Immutable.Map. The keys for the lookup values are integers (the primary key in the db). When I fetch the data all integer keys are coerced into strings. This is normal behaviour for js objects. Thus, when a lookup Map is created, the keys will be strings. Example: let colors = Immutable.Map({ '10': 'yellow', '20': 'pink', .. }) The objects

ImmutableJS: merge two list of objects, without duplicating them

我们两清 提交于 2020-01-03 19:09:23
问题 Supposing I have the below: var allFoods = Immutable.List(); var frenchFood = Immutable.List([ { 'type': 'french fries', 'price': 3 }, { 'type': 'petit gateau', 'price': 40 }, { 'type': 'croissant', 'price': 20 }, ]); var fastFood = Immutable.List([ { 'type': 'cheeseburger', 'price': 5 }, { 'type': 'vegan burger', 'price': 20 }, { 'type': 'french fries', 'price': 3 } ]); I want to merge both lists, in a way that I also remove dupes (in this case, french fries ), so the expected result would

Why is the new generics in TypeScript 2.4 causing this to fail?

六眼飞鱼酱① 提交于 2019-12-25 18:34:09
问题 So I understand that with TS 2.4 we get trickter generic checks. But what I don't understand is why now I get with this: getChannelBlockModels(i_campaign_timeline_chanel_id): Observable<List<CampaignTimelineChanelPlayersModel>> { return this.store.select(store => store.msDatabase.sdk.table_campaign_timeline_chanel_players) .map((campaignTimelineChanelPlayersModels: List<CampaignTimelineChanelPlayersModel>) => { return campaignTimelineChanelPlayersModels.filter(campaignTimelineChanelsModel =>

ImmutableJS how to simplify a filter and update logic

こ雲淡風輕ζ 提交于 2019-12-25 03:14:27
问题 The following is my structure of data [ { "id": 1, "title": "Welcome to my playground", "description": "This is so fun to play with, you will like it <3", "comments": [ { "id": 1140406, "comment": "this is an example comment", "postId": 1 } ] }, ... ] And I'm trying to use immutable js to do this operation Get all the posts Search for a post I want to add comment to Adding the comments when the post is found The following is my code posts = posts.map((post) => { if(post.get('id') == payload

Correct way to use immutablejs (toJS and fromJS) with redux

牧云@^-^@ 提交于 2019-12-24 09:14:02
问题 I wonder if this is a correct way to use immutable.js with redux and reselect (also redux-saga ). Specifically I wonder about toJS() and from fromJS() and where to use them. My idea is that: I use toJS() when sending data to a saga. I do not use fromJS() in reducer because I think that it is done anyway by the fact that I use fromJS() for initialState. Or am I wrong about that? I use toJS() in selector from reselect so I can use js data in react component. Example: 1) In my react component I

Immutable.js deleteIn not working

雨燕双飞 提交于 2019-12-23 21:21:25
问题 I have been trying to solve this problem, but there is probably something of Immutable.js that I don't catch. I hope somebody can help me to understand. I have a test like this: import {List, Map} from 'immutable'; import {expect} from 'chai'; import {setInitial, addAtListOfMembers, removeAtListOfMembers } from '../src/core'; describe('removeAtListOfMembers', () => { it('remove a member to the list of members', () => { const state = Map({ removing: 3, infos : Map(), members: Map({ 1:Map({