Skip to content

Commit

Permalink
Items can now send multiple callbacks on onDownloaded/onInstalled events
Browse files Browse the repository at this point in the history
  • Loading branch information
crautou committed Jul 26, 2018
1 parent a38afd6 commit afc89ef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions steam/ugc/Item.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ enum ItemState {
class Item {

public var id : UID;
public static var downloadedCallbacks = new Array<Item->Void>();
public static var installedCallbacks = new Array<Item->Void>();

public static function fromInt( i : Int ){
var b = haxe.io.Bytes.alloc(8);
Expand All @@ -22,11 +24,19 @@ class Item {
}

public static function init( onDownloaded : Item -> Void, onInstalled : Item -> Void ){
downloadedCallbacks.push(onDownloaded);
installedCallbacks.push(onInstalled);
Api.registerGlobalEvent(3400 + 6, function(data:{file:UID}){
onDownloaded(new Item(data.file));
var item = new Item(data.file);
for( callback in downloadedCallbacks ){
callback(item);
}
});
Api.registerGlobalEvent(3400 + 5, function(data:{file:UID}){
onInstalled(new Item(data.file));
var item = new Item(data.file);
for( callback in installedCallbacks ){
callback(item);
}
});
}

Expand Down

0 comments on commit afc89ef

Please sign in to comment.