【问题标题】:Return data & reference from falcor router从 falcor 路由器返回数据和参考
【发布时间】:2015-12-31 01:19:22
【问题描述】:

我有一条路线可以返回有关用户帐户功能的详细信息:

// games[{keys:games}].features[{integers:indices}]
{
    $type : "atom",
    value : {
        id: "6",
        count: "1",
        ...
    }
}

还有一条返回特定功能的通用详细信息的路由:

// features[{integers:features}]
{
    $type : "atom",
    value : {
        name : "fooga",
        max : 10,
        ...
    }
}

我不想将通用特征数据合并到特定于用户的数据中,因为那将是一堆数据重复,但我也希望能够在一个请求中获得所有数据

有什么聪明的方法来构造我的路由/返回的数据,以便games[{keys:games}].features[{integers:indices}] 可以返回对features[{integers:features}] 的有用引用?

我试着像这样把它们分开:

// games[{keys:games}].features[{integers:indices}].details
{
    $type : "atom",
    value : {
        id: "6",
        count: "1",
        ...
    }
}

// games[{keys:games}].features[{integers:indices}].meta
{
    $type : "ref",
    value : [
        "features",
        "15"
    ]
}

但我无法找到解决 .meta 引用的方法,而无需编写像 ...features.0.meta.[name,max,...] 这样的看似冗余的路径。理想情况下,ref 只会返回一个原子,因为它是少量数据。

【问题讨论】:

    标签: falcor falcor-router


    【解决方案1】:

    我最终把它组织成这样:

    games[{keys:games}].features[{integers:indices}].details
    games[{keys:games}].features[{integers:indices}].feature
    features[{keys:games}][{integers:features}].details
    

    丑陋的路径,但是¯\_(ツ)_/¯

    【讨论】:

      猜你喜欢
      • 2018-01-27
      • 2016-07-25
      • 2017-03-02
      • 2016-02-12
      • 2015-12-08
      • 2015-11-27
      • 2018-06-17
      • 2016-05-17
      • 2019-02-27
      相关资源
      最近更新 更多