How to use the immutable.is 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 steamerjs / steamer-react / src / js / common / immutable-pure-render-decorator.js View on Github external
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
        return false;
    }

    let keysA = Object.keys(objA);
    let keysB = Object.keys(objB);

    if (keysA.length !== keysB.length) {
        return false;
    }

    // Test for A's keys different from B.
    let bHasOwnProperty = hasOwnProperty.bind(objB);

    for (let i = 0; i < keysA.length; i++) {
        if (!bHasOwnProperty(keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
            return false;
        }
    }

    return true;
}
github steamerjs / pure-render-deepCompare-decorator / src / immutable.js View on Github external
function deepEqual(objA, objB) {
    if (objA === objB || is(objA, objB)) {
        return true;
    }

    if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
        return false;
    }

    let keysA = Object.keys(objA);
    let keysB = Object.keys(objB);

    if (keysA.length !== keysB.length) {
        return false;
    }

    // Test for A's keys different from B.
    let bHasOwnProperty = hasOwnProperty.bind(objB);
github euphoria-io / heim / client / lib / Tree.js View on Github external
entry.parent = '__root'
    }

    const newId = entry.id
    let newNode = this._node(entry)
    const parentId = entry.parent

    if (parentId) {
      const parentNode = this.index[parentId]
      if (parentNode) {
        const siblings = parentNode.get('children')
        const canAppend = siblings.size === 0 || entry[this.sortProp] >= this.index[siblings.last()].get(this.sortProp)
        if (canAppend) {
          // avoiding a re-sort can save a lot of time with large child lists
          this.index[parentId] = parentNode.set('children', siblings.delete(newId).add(newId))
          if (!Immutable.is(parentNode, this.index[parentId])) {
            _changed[parentId] = _changed[parentId] || parentNode
          }
        } else {
          this.index[parentId] = parentNode.set('children', siblings.add(newId))
          _needsSort[parentId] = true
          _changed[parentId] = _changed[parentId] || parentNode
        }
      } else {
        // create unreachable orphan parent
        this.index[parentId] = this._node().set('id', parentId).mergeIn(['children'], [newId])
        _changed[parentId] = _changed[parentId] || true
        this.size++
        _needsSort[parentId] = true
      }
    }
github shunwuyu / lesson_md / react / react-redux-order / src / pages / home / home.jsx View on Github external
componentWillReceiveProps(nextProps){
    if(!is(fromJS(this.props.proData), fromJS(nextProps.proData))){
      this.initData(nextProps);
    }
  }
github hugollm / true-store / src / observer.js View on Github external
callIfNeeded(oldMap, newMap) {
        if (this.keys.length === 0 && !Immutable.is(oldMap, newMap))
            return this.trigger('*');
        for (let i in this.keys)
            if (this.stateKeyChanged(this.keys[i], oldMap, newMap))
                return this.trigger(this.keys[i]);
    }
github ello / webapp / src / pages / EditorialPage.js View on Github external
shouldComponentUpdate(nextProps) {
    return !Immutable.is(nextProps.pageHeader, this.props.pageHeader) ||
      ['dpi'].some(prop =>
        nextProps[prop] !== this.props[prop],
      )
  }
github optimizely / nuclear-js / src / evaluator.js View on Github external
__isCached(state, getter) {
    return (
      this.__cachedGetters.hasIn([getter, 'value']) &&
      Immutable.is(this.__cachedGetters.getIn([getter, 'state']), state)
    )
  }
github zzlw / webpack-dev-super / src / common / template.jsx View on Github external
shouldComponentUpdate(nextProps, nextState) {
            return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state),fromJS(nextState))
        }
    }
github kenCode-de / bitshares-wallet / dev / app / dl / src / rpc_api / WebSocketRpc.js View on Github external
if (params[1] === "set_subscribe_callback" || params[1] === "subscribe_to_market" ||
            params[1] === "broadcast_transaction_with_callback" || params[1] === "set_pending_transaction_callback" 
            ) 
        {
            this.subscriptions[this.current_callback_id] = {
                callback: params[2][0],
                params: Immutable.fromJS(params[2][1])
            };
            params[2][0] = this.current_callback_id;
        }

        if( params[1] === "unsubscribe_from_market" || params[1] === "unsubscribe_from_accounts") {
            let unSubParams = Immutable.fromJS(params[2][0]);
            for (let id in this.subscriptions) {
                if (Immutable.is(this.subscriptions[id].params, unSubParams)) {
                    this.unsub[this.current_callback_id] = id;
                    break;
                }
            }
        }

        var request = {
            method: "call",
            params: params
        };
        request.id = this.current_callback_id;


        return new Promise((resolve, reject) => {
            this.callbacks[this.current_callback_id] = {
                time: new Date(),
github drd / jsxlate / lib / jsxlate.js View on Github external
function validateTranslation(translation, original) {
    if (!I.is(countOfReactComponentsByName(translation), countOfReactComponentsByName(original))) {
        throw new InputError('The translation has a different set of React components than the original.');
    }
    if (!I.is(countOfNamedExpressionsByName(translation), countOfNamedExpressionsByName(original))) {
        throw new InputError('The translation has a different set of expressions than the original.');
    }

    return translation;
}