immutable#List JavaScript Examples
The following examples show how to use
immutable#List.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: web-api-utils.js From ThreatMapper with Apache License 2.0 | 7 votes |
export function buildUrlQuery(params = makeMap(), state) {
// Attach the time travel timestamp to every request to the backend.
params = params.set('timestamp', getSerializedTimeTravelTimestamp(state));
// Ignore the entries with values `null` or `undefined`.
return params
.map((value, param) => {
if (value === undefined || value === null) return null;
if (List.isList(value)) {
value = value.join(',');
}
return `${param}=${value}`;
})
.filter(s => s)
.join('&');
}
Example #2
Source File: web-api-utils.js From ThreatMapper with Apache License 2.0 | 7 votes |
export function buildUrlQuery(params = makeMap(), state = null) {
// Attach the time travel timestamp to every request to the backend.
if (state) {
params = params.set('timestamp', state.get('pausedAt'));
}
// Ignore the entries with values `null` or `undefined`.
return params.map((value, param) => {
if (value === undefined || value === null) return null;
if (List.isList(value)) {
value = value.join(',');
}
return `${param}=${value}`;
}).filter(s => s).join('&');
}
Example #3
Source File: config.js From AlgorandStudio with GNU General Public License v3.0 | 6 votes |
contracts = {
default: Immutable.fromJS({
local: {
selected: '',
tabs: [],
},
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['local', 'tabs'], (tabs = List([])) => tabs)
},
SELECT_CONTRACT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.contract)
},
SET_CONTRACT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
}
}
Example #4
Source File: setIn.js From Lynx with MIT License | 6 votes |
mergeLists = function mergeLists(originalList, value) {
if (originalList && List.isList(originalList)) {
return originalList.map(function (originalListValue, index) {
return undefinedArrayMerge(value.get(index), originalListValue);
}).concat(value.slice(originalList.size));
}
return value;
}
Example #5
Source File: setIn.js From Lynx with MIT License | 6 votes |
/*
* ImmutableJS' setIn function doesn't support array (List) creation
* so we must pre-insert all arrays in the path ahead of time.
*
* Additionally we must also pre-set a dummy Map at the location
* of an array index if there's parts that come afterwards because
* the setIn function uses `{}` to mark an unset value instead of
* undefined (which is the case for list / arrays).
*/
export default function setIn(state, field, value) {
var path = _toPath(field);
if (!field || typeof field !== 'string' || !arrayPattern.test(field)) {
var newState = assureComplexProps(state, path);
return newState.setIn(path, value);
}
return state.withMutations(function (mutable) {
var _loop = function _loop(pathIndex) {
var nextPart = path[pathIndex + 1];
if (isNaN(nextPart)) {
return 'continue';
}
mutable = mutable.updateIn(path.slice(0, pathIndex + 1), function (value) {
return mergeLists(value, new List().set(parseInt(nextPart, 10), new Map()));
});
};
for (var pathIndex = 0; pathIndex < path.length - 1; ++pathIndex) {
var _ret = _loop(pathIndex);
if (_ret === 'continue') continue;
}
return mutable.setIn(path, value);
});
}
Example #6
Source File: keys.js From Lynx with MIT License | 6 votes |
keys = function keys(value) {
if (List.isList(value)) {
return value.map(function (i) {
return i.name;
});
}
if (Iterable.isIterable(value)) {
return value.keySeq();
}
return value ? List(plainKeys(value)) : empty;
}
Example #7
Source File: context.js From minerva with MIT License | 6 votes |
experimentReducer = (experiments, action) => {
const actions = {
fetch: () => experiments.set(action.projectId, List(action.experiments)),
create: () => {
if (experiments.has(action.projectId)) {
const target = experiments.get(action.projectId)
const newExperiments = target.unshift(action.experiment)
return experiments.set(action.projectId, newExperiments)
}
return experiments.set(action.projectId, List([action.experiment]))
},
update: () => {
const { experiment } = action
const target = experiments.get(action.projectId)
const index = target.findIndex((ex) => ex.id === experiment.id)
const newExperiments = target.set(index, experiment)
return experiments.set(action.projectId, newExperiments)
},
delete: () => {
const { experiment } = action
const target = experiments.get(action.projectId)
const newExperiments = target.filter((ex) => ex.id !== experiment.id)
return experiments.set(action.projectId, newExperiments)
}
}
return actions[action.type]()
}
Example #8
Source File: customHTML2Content.js From spring-boot-ecommerce with Apache License 2.0 | 6 votes |
createContentBlock = function createContentBlock(blockData, contentState) {
var key = blockData.key,
type = blockData.type,
text = blockData.text,
data = blockData.data,
inlineStyles = blockData.inlineStyles,
entityData = blockData.entityData;
var blockSpec = {
type: type != null ? type : 'unstyled',
text: text != null ? text : '',
key: key != null ? key : genKey(),
data: null,
characterList: List([])
};
if (data) {
blockSpec.data = fromJS(data);
}
if (inlineStyles || entityData) {
var entityKey = void 0;
if (entityData) {
var _type = entityData.type,
mutability = entityData.mutability,
_data = entityData.data;
contentState.createEntity(_type, mutability, _data);
entityKey = contentState.getLastCreatedEntityKey();
} else {
entityKey = null;
}
var style = OrderedSet(inlineStyles || []);
var charData = CharacterMetadata.create({ style: style, entityKey: entityKey });
blockSpec.characterList = List(Repeat(charData, text.length));
}
return new ContentBlock(blockSpec);
}
Example #9
Source File: observer.js From binary-bot with MIT License | 6 votes |
register(event, _action, once, unregisterIfError, unregisterAllBefore) {
if (unregisterAllBefore) {
this.unregisterAll(event);
}
const apiError = error => {
if (error.type === unregisterIfError.type) {
this.unregister('api.error', apiError);
unregisterIfError.unregister.forEach(unreg => {
if (unreg instanceof Array) {
this.unregister(...unreg);
} else {
this.unregisterAll(unreg);
}
});
}
};
if (unregisterIfError) {
this.register('api.error', apiError);
}
const action = (...args) => {
if (once) {
this.unregister(event, _action);
}
if (unregisterIfError) {
this.unregister('api.error', apiError);
}
_action(...args);
};
const actionList = this.eam.get(event);
this.eam = actionList
? this.eam.set(event, actionList.push({ action, searchBy: _action }))
: this.eam.set(event, new List().push({ action, searchBy: _action }));
}
Example #10
Source File: config.js From ConfluxStudio with GNU General Public License v3.0 | 6 votes |
contracts = {
default: Immutable.fromJS({
dev: {
selected: '',
tabs: [],
starred: [],
},
testnet: {
selected: '',
tabs: [],
starred: [],
},
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs)
},
SET_CONTRACT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SELECT_CONTRACT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.contract)
},
SET_STARRED_CONTRACTS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'starred'], List(payload.starred))
},
}
}
Example #11
Source File: Header.js From ConfluxStudio with GNU General Public License v3.0 | 6 votes |
render() {
console.debug('[render] HeaderWithRedux')
const { uiState, profile, projects, contracts, accounts, network } = this.props
const selectedProject = projects.get('selected')?.toJS() || {}
const networkList = List(networkManager.networks)
const networkGroups = networkList.groupBy(n => n.group)
const groupedNetworks = this.groupedNetworks(networkGroups)
const selectedNetwork = networkList.find(n => n.id === network) || {}
const browserAccounts = uiState.get('browserAccounts') || []
const starred = accounts.getIn([network, 'accounts'])?.toJS() || []
const starredContracts = contracts.getIn([network, 'starred'])?.toJS() || []
const selectedContract = contracts.getIn([network, 'selected']) || ''
const selectedAccount = accounts.getIn([network, 'selected']) || ''
const keypairManagerFilter = k => k.id.startsWith(prefix[network] || '0x')
return (
<Header
profile={profile}
projects={projects}
selectedProject={selectedProject}
selectedContract={selectedContract}
selectedAccount={selectedAccount}
starred={starred}
starredContracts={starredContracts}
keypairManagerFilter={keypairManagerFilter}
browserAccounts={browserAccounts}
extraContractItems={extraContractItems}
network={selectedNetwork}
networkList={groupedNetworks}
/>
)
}
Example #12
Source File: config.js From CKB-Studio with GNU General Public License v3.0 | 6 votes |
contracts = {
default: Immutable.fromJS({
local: {
selected: '',
tabs: [],
},
}),
persist: true,
actions: {
CREATE_LOCAL: {
reducer: state => state.update('local', (local = Immutable.fromJS({ selected: '', data: [] })) => local)
},
CREATE_TABS: {
reducer: state => state
.updateIn(['local', 'tabs'], (tabs = List([])) => tabs)
},
SELECT_CONTRACT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.contract)
},
SET_CONTRACT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
}
}
Example #13
Source File: Header.js From AlgorandStudio with GNU General Public License v3.0 | 6 votes |
render () {
console.debug('[render] HeaderWithRedux')
const { profile, projects, contracts, accounts, network } = this.props
const selectedProject = projects.get('selected')?.toJS() || {}
const list = List(networkManager.networks)
const networkGroups = list.groupBy(n => n.group)
const networkList = this.networkList(networkGroups)
const selectedNetwork = list.find(n => n.id === network) || {}
const starred = accounts.getIn([network, 'accounts'])?.toJS() || []
const selectedContract = contracts.getIn([network, 'selected']) || ''
const selectedAccount = accounts.getIn([network, 'selected']) || ''
return (
<Header
profile={profile}
projects={projects}
selectedProject={selectedProject}
selectedContract={selectedContract}
selectedAccount={selectedAccount}
starred={starred}
network={selectedNetwork}
networkList={networkList}
AuthModal={AuthModal}
createProject={this.setCreateProject()}
logo={this.renderLogo()}
/>
)
}
Example #14
Source File: config.js From AlgorandStudio with GNU General Public License v3.0 | 6 votes |
accounts = {
default: Immutable.fromJS({
local: {
loading: false,
selected: '',
accounts: [],
tabs: [],
}
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['local', 'tabs'], (tabs = List([])) => tabs)
},
SET_ACCOUNT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SET_STARRED: {
reducer: (state, { payload }) => state.setIn([payload.network, 'accounts'], List(payload.starred))
},
SELECT_ACCOUNT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.account)
},
REMOVE_ACCOUNT: {
reducer: (state, { payload }) => {
let index = state.getIn([payload.network, 'accounts']).indexOf(payload.account)
if (index === -1) {
return state
}
return state.updateIn([payload.network, 'accounts'], data => data.remove(index))
}
},
}
}
Example #15
Source File: Header.js From BSC-Studio with GNU General Public License v3.0 | 6 votes |
componentDidMount () {
actions.history = this.props.history
headerActions.history = this.props.history
this.setState({ networkList: List(networkManager.networks) }, this.setNetwork)
if (!networkManager.network) {
networkManager.setNetwork(networkManager.networks[0], { notify: false })
redux.dispatch('CHANGE_NETWORK_STATUS', true)
}
this.navGuard = new NavGuard(this.props.history)
}
Example #16
Source File: config.js From BSC-Studio with GNU General Public License v3.0 | 6 votes |
contracts = {
default: Immutable.fromJS({
dev: {
selected: '',
tabs: [],
starred: [],
},
testnet: {
selected: '',
tabs: [],
starred: [],
},
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs)
},
SET_CONTRACT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SELECT_CONTRACT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.contract)
},
SET_STARRED_CONTRACTS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'starred'], List(payload.starred))
},
}
}
Example #17
Source File: Header.js From Black-IDE with GNU General Public License v3.0 | 6 votes |
render() {
console.debug('[render] HeaderWithRedux');
const { uiState, profile, projects, contracts, accounts, network } =
this.props;
const selectedProject = projects.get('selected')?.toJS() || {};
const networkList = List(networkManager.networks);
const networkGroups = networkList.groupBy((n) => n.group);
const groupedNetworks = this.groupedNetworks(networkGroups);
const selectedNetwork = networkList.find((n) => n.id === network) || {};
const browserAccounts = uiState.get('browserAccounts') || [];
const starred = accounts.getIn([network, 'accounts'])?.toJS() || [];
const starredContracts =
contracts.getIn([network, 'starred'])?.toJS() || [];
const selectedContract = contracts.getIn([network, 'selected']) || '';
const selectedAccount = accounts.getIn([network, 'selected']) || '';
return (
<Header
profile={profile}
projects={projects}
selectedProject={selectedProject}
selectedContract={selectedContract}
selectedAccount={selectedAccount}
starred={starred}
starredContracts={starredContracts}
browserAccounts={browserAccounts}
network={selectedNetwork}
networkList={groupedNetworks}
AuthModal={AuthModal}
createProject={this.setCreateProject()}
logo={this.renderLogo()}
/>
);
}
Example #18
Source File: config.js From Black-IDE with GNU General Public License v3.0 | 6 votes |
contracts = {
default: Immutable.fromJS({
dev: {
selected: '',
tabs: [],
starred: [],
},
testnet: {
selected: '',
tabs: [],
starred: [],
},
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: (state) =>
state.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs),
},
SET_CONTRACT_TABS: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs)),
},
SELECT_CONTRACT: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'selected'], payload.contract),
},
SET_STARRED_CONTRACTS: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'starred'], List(payload.starred)),
},
},
}
Example #19
Source File: Header.js From CKB-Studio with GNU General Public License v3.0 | 6 votes |
render () {
console.debug('[render] HeaderWithRedux')
const { profile, projects, contracts, accounts, network } = this.props
const [networkId, chain] = network.split(':')
const selectedProject = projects.get('selected')?.toJS() || {}
const list = List(networkManager.networks)
const networkGroups = list.groupBy(n => n.group)
const networkList = this.networkList(networkGroups)
const selectedNetwork = list.find(n => n.id === networkId) || {}
const starred = accounts.getIn([network, 'accounts'])?.toJS() || []
const selectedContract = contracts.getIn([network, 'selected']) || ''
const selectedAccount = accounts.getIn([network, 'selected']) || ''
return (
<Header
profile={profile}
projects={projects}
selectedProject={selectedProject}
selectedContract={selectedContract}
selectedAccount={selectedAccount}
starred={starred}
network={selectedNetwork}
networkList={networkList}
AuthModal={AuthModal}
createProject={this.setCreateProject()}
logo={this.renderLogo()}
/>
)
}
Example #20
Source File: config.js From CKB-Studio with GNU General Public License v3.0 | 6 votes |
accounts = {
default: Immutable.fromJS({
local: {
loading: false,
selected: '',
accounts: [],
tabs: [],
}
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['local', 'tabs'], (tabs = List([])) => tabs)
},
SET_ACCOUNT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SET_STARRED: {
reducer: (state, { payload }) => state.setIn([payload.network, 'accounts'], List(payload.starred))
},
SELECT_ACCOUNT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.account)
},
REMOVE_ACCOUNT: {
reducer: (state, { payload }) => {
let index = state.getIn([payload.network, 'accounts']).indexOf(payload.account)
if (index === -1) {
return state
}
return state.updateIn([payload.network, 'accounts'], data => data.remove(index))
}
},
}
}
Example #21
Source File: config.js From Black-IDE with GNU General Public License v3.0 | 5 votes |
accounts = {
default: Immutable.fromJS({
dev: {
loading: false,
selected: '',
accounts: [],
tabs: [],
},
testnet: {
loading: false,
selected: '',
accounts: [],
tabs: [],
},
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: (state) =>
state.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs),
},
SET_ACCOUNT_TABS: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs)),
},
SET_STARRED: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'accounts'], List(payload.starred)),
},
SELECT_ACCOUNT: {
reducer: (state, { payload }) =>
state.setIn([payload.network, 'selected'], payload.account),
},
REMOVE_ACCOUNT: {
reducer: (state, { payload }) => {
let index = state
.getIn([payload.network, 'accounts'])
.indexOf(payload.account);
if (index === -1) {
return state;
}
return state.updateIn([payload.network, 'accounts'], (data) =>
data.remove(index)
);
},
},
},
}
Example #22
Source File: customHTML2Content.js From spring-boot-ecommerce with Apache License 2.0 | 5 votes |
// takes HTML string and returns DraftJS ContentState
export default function customHTML2Content(HTML, contentState) {
var tempDoc = new DOMParser().parseFromString(HTML, 'text/html');
// replace all <img /> with <blockquote /> elements
toArray(tempDoc.querySelectorAll('img')).forEach(imgReplacer);
// use DraftJS converter to do initial conversion. I don't provide DOMBuilder and
// blockRenderMap arguments here since it should fall back to its default ones, which are fine
var _convertFromHTML = convertFromHTML(tempDoc.body.innerHTML),
contentBlocks = _convertFromHTML.contentBlocks;
// now replace <blockquote /> ContentBlocks with 'atomic' ones
contentBlocks = contentBlocks.reduce(function (contentBlocks, block) {
if (block.getType() !== 'blockquote') {
return contentBlocks.concat(block);
}
var image = JSON.parse(block.getText());
contentState.createEntity('IMAGE-ENTITY', 'IMMUTABLE', image);
var entityKey = contentState.getLastCreatedEntityKey();
var charData = CharacterMetadata.create({ entity: entityKey });
// const blockSpec = Object.assign({ type: 'atomic', text: ' ' }, { entityData })
// const atomicBlock = createContentBlock(blockSpec)
// const spacerBlock = createContentBlock({});
var fragmentArray = [new ContentBlock({
key: genKey(),
type: 'image-block',
text: ' ',
characterList: List(Repeat(charData, charData.count()))
}), new ContentBlock({
key: genKey(),
type: 'unstyled',
text: '',
characterList: List()
})];
return contentBlocks.concat(fragmentArray);
}, []);
// console.log('>> customHTML2Content contentBlocks', contentBlocks);
tempDoc = null;
return BlockMapBuilder.createFromArray(contentBlocks);
}
Example #23
Source File: config.js From BSC-Studio with GNU General Public License v3.0 | 5 votes |
accounts = {
default: Immutable.fromJS({
dev: {
loading: false,
selected: '',
accounts: [],
tabs: [],
},
testnet: {
loading: false,
selected: '',
accounts: [],
tabs: [],
}
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs)
},
SET_ACCOUNT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SET_STARRED: {
reducer: (state, { payload }) => state.setIn([payload.network, 'accounts'], List(payload.starred))
},
SELECT_ACCOUNT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.account)
},
REMOVE_ACCOUNT: {
reducer: (state, { payload }) => {
let index = state.getIn([payload.network, 'accounts']).indexOf(payload.account)
if (index === -1) {
return state
}
return state.updateIn([payload.network, 'accounts'], data => data.remove(index))
}
},
}
}
Example #24
Source File: ProjectDashboard.js From minerva with MIT License | 5 votes |
ProjectDashboard = (props) => {
const { id } = useParams()
const { fetchExperiments } = useContext(GlobalContext)
const [time, setTime] = useState(Date.now())
const { datasets, projects } = props
const experiments = props.experiments.get(Number(id)) ?? List([])
const project = projects.find((p) => p.id === Number(id)) ?? Map({})
const { datasetId } = project
const dataset = datasets.find((d) => d.id === Number(datasetId)) ?? Map({})
// Fetch experiments
useEffect(() => {
fetchExperiments(Number(id))
}, [id])
// Fetch experiments periodically
useEffect(() => {
const timeoutId = setTimeout(() => {
setTime(Date.now())
fetchExperiments(Number(id))
}, FETCH_EXPERIMENTS_INTERVAL)
return () => {
clearTimeout(timeoutId)
}
}, [time])
return (
<div className='dashboard'>
<ProjectHeader project={project} dataset={dataset} />
<div className='dashboard-body-wrapper'>
<div className='dashboard-body'>
<ExperimentList
project={project}
dataset={dataset}
experiments={experiments}
/>
<ProjectMetrics experiments={experiments} project={project} />
</div>
</div>
</div>
)
}
Example #25
Source File: index.js From strapi-plugin-config-sync with MIT License | 5 votes |
initialState = fromJS({
configDiff: Map({}),
partialDiff: List([]),
isLoading: false,
appEnv: 'development',
})
Example #26
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 5 votes |
function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
// Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
// arbitrary code in whatever environment you're running this in. For an
// example of how we try to do this in-browser, see getSafeBodyFromHTML.
var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey);
if (chunk == null) {
return [];
}
var start = 0;
return chunk.text.split('\r').map(function (textBlock, blockIndex) {
// Make absolutely certain that our text is acceptable.
textBlock = sanitizeDraftText(textBlock);
var end = start + textBlock.length;
var inlines = nullthrows(chunk).inlines.slice(start, end);
var entities = nullthrows(chunk).entities.slice(start, end);
var characterList = List(inlines.map(function (style, entityIndex) {
var data = {
style: style,
entity: null
};
if (entities[entityIndex]) {
data.entity = entities[entityIndex];
}
return CharacterMetadata.create(data);
}));
start = end + 1;
return new ContentBlock({
key: generateKey(),
type: nullthrows(chunk).blocks[blockIndex].type,
data: nullthrows(chunk).blocks[blockIndex].data,
depth: nullthrows(chunk).blocks[blockIndex].depth,
text: textBlock,
characterList: characterList
});
});
}
Example #27
Source File: index.js From Lynx with MIT License | 5 votes |
emptyList = List()
Example #28
Source File: keys.js From Lynx with MIT License | 5 votes |
empty = List()
Example #29
Source File: config.js From ConfluxStudio with GNU General Public License v3.0 | 5 votes |
accounts = {
default: Immutable.fromJS({
dev: {
loading: false,
selected: '',
accounts: [],
tabs: [],
},
testnet: {
loading: false,
selected: '',
accounts: [],
tabs: [],
}
}),
persist: true,
actions: {
CREATE_TABS: {
reducer: state => state
.updateIn(['dev', 'tabs'], (tabs = List([])) => tabs)
},
SET_ACCOUNT_TABS: {
reducer: (state, { payload }) => state.setIn([payload.network, 'tabs'], Immutable.fromJS(payload.tabs))
},
SET_STARRED: {
reducer: (state, { payload }) => state.setIn([payload.network, 'accounts'], List(payload.starred))
},
SELECT_ACCOUNT: {
reducer: (state, { payload }) => state.setIn([payload.network, 'selected'], payload.account)
},
REMOVE_ACCOUNT: {
reducer: (state, { payload }) => {
let index = state.getIn([payload.network, 'accounts']).indexOf(payload.account)
if (index === -1) {
return state
}
return state.updateIn([payload.network, 'accounts'], data => data.remove(index))
}
},
}
}