[fix] onresourceready: set previous resource to globals after all callbacks