mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-11-03 18:39:19 +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,7 +40,9 @@ 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
 | 
				
			||||||
			callback(entity, id, value)
 | 
								if callback ~= nil then
 | 
				
			||||||
 | 
									callback(entity, id, value)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue