How to use the immutable.Set function in immutable

To help you get started, we’ve selected a few immutable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gxchain / gxchain-light / web / app / components / Account / AccountVoting.jsx View on Github external
updateAccountData(account) {
        let options = account.get("options");
        let proxy_account_id = options.get("voting_account");
        if (proxy_account_id === "1.2.5") {
            proxy_account_id = "";
        }

        let votes = options.get("votes");
        let vote_ids = votes.toArray();
        // remove workers
        vote_ids = vote_ids.filter(id => {
            return id.split(":")[0] != '2';
        });
        let vids = Immutable.Set(vote_ids);
        ChainStore.getObjectsByVoteIds(vote_ids);
        FetchChainObjects(ChainStore.getObjectByVoteID, vote_ids, 5000).then(vote_objs => {
            //console.log( "Vote Objs: ", vote_objs );
            let witnesses = new Immutable.List();
            let committee = new Immutable.List();
            let workers = new Immutable.Set();
            vote_objs.forEach(obj => {
                let account_id = obj.get("committee_member_account");
                if (account_id) {
                    committee = committee.push(account_id);
                } else if (account_id = obj.get("worker_account")) {
                    // console.log( "worker: ", obj );
                    //     workers = workers.add(obj.get("id"));
                } else if (account_id = obj.get("witness_account")) {
                    witnesses = witnesses.push(account_id);
                }
github peerplays-network / peerplays-core-gui / src / stores / to_rm / AccountRefsStore.js View on Github external
constructor() {
    super();
    this._export('loadDbData');
    this.state = this._getInitialState();
    this.bindListeners({onAddPrivateKey: PrivateKeyActions.addKey});
    this.no_account_refs = Immutable.Set(); // Set of account ids
    ChainStore.subscribe(this.chainStoreUpdate.bind(this));
  }
github bitshares / bitshares-ui / dl / src / stores / AccountRefsStore.js View on Github external
checkPrivateKeyStore() {
        var no_account_refs = this.no_account_refs
        var account_refs = Immutable.Set()
        PrivateKeyStore.getState().keys.keySeq().forEach( pubkey => {
            if(no_account_refs.has(pubkey)) return
            var refs = ChainStore.getAccountRefsOfKey(pubkey)
            if(refs === undefined) return
            if( ! refs.size) {
                // Performance optimization... 
                // There are no references for this public key, this is going
                // to block it.  There many be many TITAN keys that do not have
                // accounts for example.
                {
                    // Do Not block brainkey generated keys.. Those are new and
                    // account references may be pending.
                    var private_key_object = PrivateKeyStore.getState().keys.get(pubkey)
                    if( typeof private_key_object.brainkey_sequence === 'number' ) {
                        return
                    }
github MichaelMure / Arbore / app / models / ContactList.js View on Github external
export const LOCAL_DATA_VERSION = 1

export const writable = {
  directory: 'directory',
  selectedPubkey: 'selectedPubkey',
  search: 'search',
  pool: 'pool',
  graph: 'graph',
  rejected: 'rejected',
  follower: 'follower',
}

export const ContactListRecord = Record({
  dataVersion: LOCAL_DATA_VERSION,
  directory: Set(),
  selectedPubkey: null,
  search: '',
  pool: Map(),
  graph: Map(),
  rejected: Set(),
  follower: Set(),
}, 'ContactList')

export default class ContactList extends ContactListRecord {
  dataVersion: number

  // the actual contact list of the user
  directory: Set
  // the contact's pubkey selected in the UI
  selectedPubkey: ?string
  // the current search pattern
github duckpunch / godash / src / analysis.js View on Github external
export function liberties(board, position) {
    return group(board, position).reduce(
        (acc, pos) => acc.union(matchingAdjacentPositions(board, pos, EMPTY)),
        Set()
    ).size;
}
github luckymarmot / Paw-cURLImporter / src / TestUtils.js View on Github external
assertEqualElements(a, b) {
        assert.isTrue(Immutable.is(Immutable.Set(Immutable.fromJS(a)),
                                   Immutable.Set(Immutable.fromJS(b))),
                      `${a} !== ${b}`)
    }
github hoppinger / MonadicReact / dist / react_monad / html.js View on Github external
function MultiSelector(props, context) {
        var _this = _super.call(this, props, context) || this;
        _this.state = { selected: Immutable.Set(props.selected_items != undefined ?
                props.items.map(function (i, i_index) { return [props.to_string(i), i_index]; })
                    .filter(function (x) { return props.selected_items.some(function (selected) { return props.to_string(selected) == x[0]; }); })
                    .map(function (x) { return x[1]; })
                    .toArray()
                :
                    []) };
        return _this;
    }
    MultiSelector.prototype.componentWillMount = function () {
github duckpunch / godash / src / board.js View on Github external
export function liberties(board, coordinate) {
    return group(board, coordinate).reduce(
        (acc, coord) => acc.union(matchingAdjacentCoordinates(board, coord, EMPTY)),
        Set(),
    );
}
github oVirt / ovirt-web-ui / src / reducers / vms.js View on Github external
} from '_/constants'
import { actionReducer, removeMissingItems } from './utils'
import { sortFields } from '_/utils'

const EMPTY_MAP = Immutable.fromJS({})
const EMPTY_ARRAY = Immutable.fromJS([])

const initialState = Immutable.fromJS({
  vms: {},
  pools: {},
  filters: EMPTY_MAP,
  sort: { ...sortFields[0], isAsc: true },

  page: 1,

  missedVms: Immutable.Set(),

  /**
   * true ~ we need to fetch further vms and pools
   * false ~ all visible entities already fetched
   */
  notAllPagesLoaded: true,

  correlationResult: {},
})

const vms = actionReducer(initialState, {
  [UPDATE_VMS] (state, { payload: { vms, copySubResources, page } }) {
    const updates = {}

    vms.forEach(vm => {
      if (!state.getIn(['vms', vm.id])) {
github danscan / fractal / app / vendor / pro-inputs / src / components / CheckButtonsGroup / index.js View on Github external
toggleSelectedValuesMember(value) {
    const {
      onChangeSelectedValues,
      selectedValues,
    } = this.props;
    const selectedValuesSet = new Set(selectedValues);
    let newSelectedValues;

    if (selectedValuesSet.has(value)) {
      newSelectedValues = selectedValuesSet
        .delete(value)
        .toArray();
    } else {
      newSelectedValues = selectedValuesSet
        .add(value)
        .toArray();
    }

    return onChangeSelectedValues(newSelectedValues);
  }