willowtreeapps/spruce-ios

Can't create custom `SortFunction`s

zackdotcomputer opened this issue · 1 comments

The current setup of SortFunction.swift makes it impossible to create custom instances of SortFunctions because:

  1. SortFunction is public, implying that the intention is that developers should be able to conform to it and create custom sorts.
  2. SortFunction requires two functions, each of which are expected to return [TimedView].
  3. However, TimedView has two properties, each of which have no access modifiers (and so default to internal), and which has no init method (and so one is autogenerated and defaults to internal).
  4. Because TimedView's init and properties are all internal, they can't be viewed from outside of the compiled target and, thus, it is impossible to construct a new instance of a TimedView. This means it's impossible to make one to return from the required functions and so it is impossible to actually subclass SortFunction.

I recommend we create a public init method for this struct to fix this issue. I'll submit a PR shortly to do that.

Resolved by merging of #109 - thanks @eriklamanna