Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Make the core model/state of the search (SearchParameter) immutable (for real) #105

Merged
merged 19 commits into from
Jun 15, 2015

Conversation

bobylito
Copy link
Contributor

The point of this pull request is to provide real immutability for the state of the search that is encapsulated into the helper (helper.state)

In practice, this will help to easily test that the previous state is different from the current by comparing references. It will also help test properties for the future, you can now easily modify the model without having to revert the changes.

var state0 = SearchParameters.make( {
  disjunctiveFacets : [ "facet" ]
} );

var state1 = state0.addDisjunctiveRefinement( "facet", "value" );

state0 !== state1 //true
deepEqual( state0, state1 ); // false

//actually

state0.disjunctiveRefinements !== state1.disjunctiveRefinements;

/**
* Clear all or parts of a RefinementList. Depending on the arguments, three
* behaviors can happen :
* - if not attribute is provided : clears the whole list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/not/no/

@pixelastic
Copy link
Contributor

LGTM 👍

@vvo
Copy link
Contributor

vvo commented Jun 15, 2015

✅ reviewed

@bobylito
Copy link
Contributor Author

Thanks @vvo @pixelastic

bobylito added a commit that referenced this pull request Jun 15, 2015
FIX #14 Make the core model/state of the search (SearchParameter) immutable (for real)
@bobylito bobylito merged commit c1e50f0 into master Jun 15, 2015
@bobylito bobylito deleted the feature/mutability branch June 15, 2015 12:36
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
…eature/mutability

FIX algolia/algoliasearch-helper-js#14 Make the core model/state of the search (SearchParameter) immutable (for real)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants