小编Lui*_*Rol的帖子

FlatList 标头中有多个元素

有没有什么方法可以将元素数组传递给 FlatList 而不使用包装器,以便我以后stickyHeaderIndices={[1]}可以只使第二个元素具有粘性?

我的意图是将非粘性标题与粘性工具栏一起使用并将它们传递给组件。

如果我尝试将 renderHeader 作为函数传递给 ListHeaderComponent,例如

  renderHeader = () => {
    const { toolbar, header } = this.props;
    const arr = [header(), toolbar()];
    return arr;
  };
Run Code Online (Sandbox Code Playgroud)

我得到一个

Invariant Violation: Invariant Violation: Invariant Violation: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `VirtualizedList`.
Run Code Online (Sandbox Code Playgroud)

实现该行为的另一种方法是什么(即)有一个列表,其中只有第二个标题变得粘滞?

我尝试的另一种方法是声明一个带有 3 个孩子的滚动视图:

The non-sticky header
The toolbar
The flatlist itself
Run Code Online (Sandbox Code Playgroud)

stickyHeaderIndices={[1]}ScrollView 上设置时。 …

react-native react-native-flatlist

4
推荐指数
1
解决办法
2014
查看次数

正在重新传递ActiveMQ的消息(PooledConnectionFactory misconfig suspect)

我有一个应用程序,它使用Spring MessageListenerContainers和ActiveMQ.我已将其配置为使用PooledConnectionFactory,遵循activemq的文档.

我的方案如下:

  • 队列中有两个java-app使用者(2个不同的tomcats)
  • 主从属activemq代理,具有故障转移URL
  • 已配置PooledConnectionFactory
  • 骆驼在应用程序上
  • activemq 5.8.0,commons-pool 1.6

一切似乎都运行正常,但偶尔会将消息重新传递给消费者,这会导致应用程序错误.

在日志之后我怀疑这个错误是由Spring的PooledConnectionFactory bean定义中的一些错误配置引起的,该定义关闭甚至使用的连接然后强制在当前会话上回滚并因此重新传递消息

池的spring配置如下:

<bean id="AMQconnFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
            <value>${activemq_url}?initialReconnectDelay=100&amp;timeout=3000&amp;jms.prefetchPolicy.all=1&amp;jms.redeliveryPolicy.initialRedeliveryDelay=300000
            </value>
        </property>
    </bean>
    <bean id="sharedConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" abstract="true">
        <property name="connectionFactory" ref="AMQconnFactory" />
        <property name="maxConnections" value="30" />
    </bean>

    <bean id="MotionJMSConnectionFactory" parent="sharedConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
        init-method="start" destroy-method="stop" />

<bean id="sharedListenersProps" abstract="true" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="maxConcurrentConsumers" value="1" />
        <property name="concurrentConsumers" value="1" />
        <property name="connectionFactory" ref="MotionJMSConnectionFactory" />
        <property name="sessionTransacted" value="true" />
        <property name="transactionTimeout" value="300"/>
    </bean>
Run Code Online (Sandbox Code Playgroud)

指向我的方向的日志如下:

[TRACE] (ActiveMQMessageConsumer.java:494) (09:48:16,412) - ID:bbiovx01.bglobal.bcorp-56155-1365791814916-1:3222:1:1 received message: MessageDispatch {commandId = 0, responseRequired …
Run Code Online (Sandbox Code Playgroud)

spring activemq-classic pool

3
推荐指数
1
解决办法
9718
查看次数

SimpleInjector生成多个实例

我在使用simpleInjector时遇到了一个奇怪的行为.

以下代码说明了我的方案:

class A: IA, IB<D>{}
Run Code Online (Sandbox Code Playgroud)

然后,我正在为每个接口的实例注册一次,如下所示:

foreach (var service in typeof(A).GetInterfaces())
{
    container.RegisterSingle(service, typeof(A));
}
Run Code Online (Sandbox Code Playgroud)

我的目标是能够使用IA或IB检索A的相同实例(单例).IB代表eventlistener接口.

在A的构造函数上设置断点我可以看到它在调用 container.verify()方法时被调用两次,这意味着我在这里没有单例.

这种情况有什么问题?我是否需要以不同的方式威胁泛型界面?

c# simple-injector

2
推荐指数
1
解决办法
643
查看次数

将同一提供程序的两个实例嵌套JS

嗨,在一个测试套件上,我看来我有两个同一提供者的活动实例,一个实例用于实现,另一个实例用于实际实现。

我的结论基于这样一个事实:在测试中,我尝试用jest.fn调用替换方法,但仍然在我测试的服务上,该方法仍指向原始实现。

更奇怪的是,我能够模拟另一个执行完全相同的过程的服务,好像取决于这些服务的注入方式(它们来自容器图中的位置)是否起作用。

我将尝试分享一些片段,但是,当然,只有一个很小的回购实际上可以重现它,但是也许有人有一个见解:

 beforeAll(async done => {
    app = await Test.createTestingModule({
      imports: [
        SOME_MODULES,
      ],
      providers: [
        EssayApplicationService,
        ReviewFacade,
        ExamCacheResultService,
      ],
    }).compile();

    essayApplicationService = app.get<EssayApplicationService>(EssayApplicationService)
    reviewFacade = app.get<ReviewFacade>(ReviewFacade)
    examCacheResult = app.get<ExamCacheResultService>(ExamCacheResultService)
    await app.init()
    done()
  })
Run Code Online (Sandbox Code Playgroud)
it('should invoke review only once', async done => {

    reviewFacade.startReview = jest.fn() --> this works
    examCacheResult.clearCachedResult = jest.fn() --> this fails

    await essayApplicationService.finishApplication()

    expect(reviewFacade.startReview).toHaveBeenCalledTimes(1)
    expect(reviewFacade.startReview).toHaveBeenCalledWith(expect.objectContaining({ id: 1 }))
    expect(examCacheResult.clearCachedResult).toHaveBeenCalledTimes(1) ---> here this fails, although it's called!!
Run Code Online (Sandbox Code Playgroud)

因此,问题归结为以下事实:对于测试中的服务调用了这两种方法,我100%表示肯定,但是由于某种原因第二种方法并未被模拟代替

javascript node.js typescript jestjs nestjs

1
推荐指数
1
解决办法
609
查看次数