if  parameter is a function, use that function as stream agent
Merge pull request #136 from sidorares/stream-factory

if  parameter is a function, use that function as stream agent