Can you please guide me in StreamData bind function?

From the example in the documentation, I can’t figure out how it could work.

Please check the following. I get error
** (ArgumentError) expected a generator, which can be a %StreamData{} struct, an atom, or a tuple with generators in it, but got: %{"asset_id" => ""}

which it make sense, however I don’t know how else I can do it.

      project_gen =  constant(%{"project_id" => project.id})
      tasks_value_list = list_of(Factory.my_terms(), min_length: 5)
      task_gen = map_of(constant("tasks"), tasks_value_list, length: 1)
      asset_gen = map_of(constant("asset_id"), Factory.my_terms, length: 1)
      data = bind(task_gen, fn(a_task_map_list) -> 
        bind(map_of(constant("asset_id"), Factory.my_terms, length: 1), 
                             fn(an_asset) ->
          list_of( map_of(an_asset, a_task_map_list), length: 1)
        end)
      end)

The above is the start of generating the following data structure:

 %{"project_id" => project_id,
      "tasks" => [ %{"asset_id" => 10, "tasks" => []},
                          %{"asset_id" => <<170, 87>>, "tasks" => [ <<203, 121>>, :L, :K6, 2, "%H" ]} 
         ] }

Thank you in advance

2 Likes