@@ -24,7 +24,7 @@ import * as Layer from "effect/Layer"
2424import * as MutableHashMap from "effect/MutableHashMap"
2525import * as Option from "effect/Option"
2626import { type Pipeable , pipeArguments } from "effect/Pipeable"
27- import { hasProperty } from "effect/Predicate"
27+ import { hasProperty , isObject } from "effect/Predicate"
2828import type { ReadonlyRecord } from "effect/Record"
2929import * as Runtime from "effect/Runtime"
3030import * as Schema from "effect/Schema"
@@ -421,31 +421,31 @@ const makeRead: {
421421 | A ,
422422 options ?: { readonly initialValue ?: unknown }
423423) => {
424- if ( typeof arg === "function" ) {
424+ if ( typeof arg === "function" && ! Effect . isEffect ( arg ) && ! ( Stream . StreamTypeId in arg ) ) {
425425 const create = arg as ( get : Context ) => any
426426 return function ( get : Context , providedRuntime ?: Runtime . Runtime < any > ) {
427427 const value = create ( get )
428- if ( typeof value === "object" && value !== null ) {
428+ if ( isObject ( value ) ) {
429429 if ( isDataType ( value ) ) {
430430 return value
431431 } else if ( Effect . EffectTypeId in value ) {
432432 return effect ( get , value as any , options , providedRuntime )
433433 } else if ( Stream . StreamTypeId in value ) {
434- return stream ( get , value , options , providedRuntime )
434+ return stream ( get , value as any , options , providedRuntime )
435435 }
436436 }
437437 return value
438438 }
439- } else if ( typeof arg === "object" && arg !== null ) {
439+ } else if ( isObject ( arg ) ) {
440440 if ( isDataType ( arg ) ) {
441441 return state ( arg )
442442 } else if ( Effect . EffectTypeId in arg ) {
443443 return function ( get : Context , providedRuntime ?: Runtime . Runtime < any > ) {
444- return effect ( get , arg , options , providedRuntime )
444+ return effect ( get , arg as any , options , providedRuntime )
445445 }
446446 } else if ( Stream . StreamTypeId in arg ) {
447447 return function ( get : Context , providedRuntime ?: Runtime . Runtime < any > ) {
448- return stream ( get , arg , options , providedRuntime )
448+ return stream ( get , arg as any , options , providedRuntime )
449449 }
450450 }
451451 }
0 commit comments