ps.factory method to create a stream from a callback function