Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add test example for double equatable check#259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mjarvis wants to merge5 commits intomaster
base:master
Choose a base branch
Loading
frommjarvis/double-skip

Conversation

@mjarvis
Copy link
Member

Having a default implementation forskipRepeats when the selected state is equatable causes what could be a performance issue when the user implements their ownskipRepeats.
The original default implementation is still called, even though a default exists.
This could also cause unwanted behaviour if the custom skipRepeats wants to compare something not checked in the default equatable.

Having a default implementation for `skipRepeats` when the selected state is equatable causes what could be a performance issue when the user implements their own `skipRepeats`.The original default implementation is still called, even though a default exists.This could also cause unwanted behaviour if the custom skipRepeats wants to compare something not checked in the default equatable.
varvalue:Int=0
varcustomEquatCount:Int=0

staticfunc==(left:CustomEquatable, right:CustomEquatable)->Bool{

Choose a reason for hiding this comment

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

Operator Function Whitespace Violation: Operators should be surrounded by a single whitespace when defining them. (operator_whitespace)

@mjarvis
Copy link
MemberAuthor

This intentionally fails to demonstrate what may be undesirable behaviour.
My first theory for avoiding this would be to haveselect when Equatable return a different subscription type, which, if the user callsskipRepeats on, discards its prior, default skipRepeats implementation.
However, before I go ahead and try and find a solution, I wanted to open the discussion in case others think this behaviour is fine / desirable.

@DivineDominion
Copy link
Contributor

DivineDominion commentedNov 19, 2017
edited
Loading

I swear we had a user report confusion about this somewhere, recently. Cannot find the issue, though.

It does not make sense toskipRepeats eagerly; I'd definitely postpone this to the last possible moment, just like you said:

My first theory for avoiding this would be to have select when Equatable return a different subscription type, which, if the user calls skipRepeats on, discards its prior, default skipRepeats implementation.

I think something among the lines of aLazySkipRepeatsSubscription<T> (OrLazyFilteredSubscription) could do the trick. It can use a chain of subscriptions under the hood, delegatingselect calls to itself to the underlying subscriptionsuntil the selected substate is not skippable anymore.

Then more expressibe types can aid; the generalSubscription becomes aSubstateSubscription andSkipRepeatsSubscription (orFilteredSubscription) etc. so the type system takes care of conveying if something was skipped anywhere, yet.

Writing it down like this makes me realize we are operating on types called "subscription", which conveys the connection to the store is already established but subsequently modified. What about renaming the stuff we callskipRepeats andselect on something more skin to "stream of state updates"? Then aSubscription type is just the end result and we can insert as many helper types as we need without causing confusion for subscription setup.StateUpdate,FilteredUpdate<T: StateUpdate>,SubstateSelection<T: StateUpdate>. ThenStore.subscribe((StateUpdate) -> StateUpdate) conveys that you subscribe to the store via state updates that you can modify. How's that sound?

I'd like to help cook something like this up if it resonates with you.

I propose we pick this issue up one way or another, and@mjarvis what do you think about a title like "[WIP] Avoid multiple calls to skipRepeats for substates" or something?

@mjarvismjarvis mentioned this pull requestDec 4, 2017
@DivineDominion
Copy link
Contributor

@mjarvis Since we never managed to get#307 to work, do you have an opinion on the renaming ofsubscribe return type names? I can just go ahead and implement it as you proposed to make it quick.

@mjarvis
Copy link
MemberAuthor

@DivineDominion I gave this a try a while back but was unable to resolve the problem. You're welcome to take a crack at it.

@AlexanderBollbach
Copy link

AlexanderBollbach commentedJun 5, 2018
edited
Loading

so i ran into this issue and incurred performance hits in my app. i calledskipRepeats to insert a specific equality checking closure that was optimized for the specific StoreSubscriber (as one does), but that closure was never invoked. also, just to be clear (if slightly pedantic), we're talking about the closure argument toskipRepeats and not the "skipRepeats implementation" that the user of ReSwift implements, right?

Malcolm Jarvis added2 commitsJanuary 17, 2019 15:07
#262 partially resolved this issue by removing automatic skips from sub-state selections, however we still have an issue where the original Store subscription creation creates a skipRepeats which is unnecessary, since we're providing a smaller subset skipRepeats in our explicit subscription.This adjusts the test fake to make our main state Equatable, which surfaces a double skipRepeats issue again.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@houndci-bothoundci-bothoundci-bot left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@mjarvis@DivineDominion@AlexanderBollbach@houndci-bot

[8]ページ先頭

©2009-2025 Movatter.jp