-
-
Save deanwampler/179537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.SwingWorker | |
class A { | |
def loadAll(f:(Int) => List[String]): List[String] = List("a") | |
def getFriendsIds(page: Int): List[String] = List("a") | |
def getFollowersIds(page: Int): List[String] = List("a") | |
} | |
class B { | |
def setFollowers(followers: List[String]) {} | |
def setFriends(friends: List[String]) {} | |
} | |
object Temp { | |
def main(args: Array[String]): Unit = { | |
val a = new A | |
val b = new B | |
new SwingWorker[List[String], Object] { | |
def doInBackground = a.loadAll(a.getFollowersIds) | |
override def done = b.setFollowers(get) | |
}.execute | |
new SwingWorker[List[String], Object] { | |
def doInBackground = a.loadAll(a.getFriendsIds) | |
override def done = b.setFriends(get) | |
}.execute | |
} | |
} | |
// How to eliminate duplication (four lines starting "new SwingWorker")? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment