Comparison

util/pubsub.lua @ 8343:5df2f240173b

util.pubsub: Return an empty list if specific item asked for does not exist (thanks jonasw)
author Kim Alvefur <zash@zash.se>
date Wed, 18 Oct 2017 21:21:43 +0200
parent 8333:2abbb01cd756
child 8376:eb6a9c314c86
comparison
equal deleted inserted replaced
8342:0c0990a575de 8343:5df2f240173b
336 return false, "item-not-found"; 336 return false, "item-not-found";
337 end 337 end
338 if id then -- Restrict results to a single specific item 338 if id then -- Restrict results to a single specific item
339 local with_id = self.data[node]:get(id); 339 local with_id = self.data[node]:get(id);
340 if not with_id then 340 if not with_id then
341 return false, "item-not-found"; 341 return true, { };
342 end 342 end
343 return true, { id, [id] = with_id }; 343 return true, { id, [id] = with_id };
344 else 344 else
345 local data = {} 345 local data = {}
346 for key, value in self.data[node]:items() do 346 for key, value in self.data[node]:items() do