Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buggy... but got stock quotes working the same??/
- Loading branch information
Showing
7 changed files
with
60 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package stocks.control | ||
{ | ||
import flash.events.Event; | ||
|
||
import mx.rpc.events.ResultEvent; | ||
|
||
import net.seanhess.glue.Respond; | ||
|
||
import stocks.model.Quote; | ||
import stocks.service.IQuoteService; | ||
import stocks.service.QuoteServiceParser; | ||
|
||
public class Quotes | ||
{ | ||
public var quoteService:IQuoteService; | ||
public var parser:QuoteServiceParser; // not an interface, but you could extend it to mock it | ||
|
||
public function getQuote(quote:Quote):void | ||
{ | ||
var respond:Respond = new Respond(quoteService, quote); | ||
respond.result(onResult); | ||
respond.fault(onFault); | ||
|
||
quoteService.getQuote(quote.symbol); | ||
} | ||
|
||
private function onResult(event:ResultEvent, respond:Respond):void | ||
{ | ||
var quote:Quote = respond.data as Quote; | ||
quote.price = parser.getPrice(event.result); | ||
} | ||
|
||
private function onFault(event:Event):void | ||
{ | ||
trace("There was an error"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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