mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-04 02:49:18 +00:00 
			
		
		
		
	Make callback optional
This commit is contained in:
		
							parent
							
								
									6dfb428296
								
							
						
					
					
						commit
						a9891abf6d
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
					@ -7,7 +7,7 @@ export type PatchedWorld = jecs.World & {
 | 
				
			||||||
	observer: <T...>(
 | 
						observer: <T...>(
 | 
				
			||||||
		PatchedWorld,
 | 
							PatchedWorld,
 | 
				
			||||||
		jecs.Query<T...>,
 | 
							jecs.Query<T...>,
 | 
				
			||||||
		(jecs.Entity) -> ()
 | 
							(<a>(jecs.Entity, jecs.Id<a>, a) -> ())?
 | 
				
			||||||
	) -> () -> (jecs.Entity),
 | 
						) -> () -> (jecs.Entity),
 | 
				
			||||||
	monitor: (
 | 
						monitor: (
 | 
				
			||||||
		PatchedWorld,
 | 
							PatchedWorld,
 | 
				
			||||||
| 
						 | 
					@ -40,9 +40,11 @@ local function observers_new(world, query, callback)
 | 
				
			||||||
		if jecs.query_match(query, archetype) then
 | 
							if jecs.query_match(query, archetype) then
 | 
				
			||||||
			i += 1
 | 
								i += 1
 | 
				
			||||||
			entities[i] = entity
 | 
								entities[i] = entity
 | 
				
			||||||
 | 
								if callback ~= nil then
 | 
				
			||||||
				callback(entity, id, value)
 | 
									callback(entity, id, value)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, term in terms do
 | 
						for _, term in terms do
 | 
				
			||||||
		world:added(term, emplaced)
 | 
							world:added(term, emplaced)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue