In ngrx effect the operator after concatLatestFrom marks the action as type never - ngrx

I'm getting a TypeScript syntax error in the filter operator saying Property "searchCriteria" does not exist on type "never".
I must be failing in my understanding of concatLatestFrom because I can't get this operator to work (compile) in the effect and I can't find any other places where people are having a similar issue.
loadSearchResults$ = createEffect(() => this.actions$.pipe(
ofType(searchActions.SearchApi.type),
concatLatestFrom((action) =>
this.searchStore.pipe(select(fromSearchSelectors.getSelectedRecordRangeResults))),
filter(([action, recordResultList]) => !recordResultList[createRowID(action.searchCriteria.recordRange)]),

Found the problem, ofType(searchActions.SearchApi.type) needed only ofType(searchActions.SearchApi). So I didn't need to give the "type" off the creator class.

Related

Trying to decode an event using rescript-json-combinators

Trying to create an equivalent for decodeEvent using rescript-json-combinators. I couldn't figure out how to replace "Decoder(decoder)" since Decoders have been made abstract in rescript-json-combinators. Trying to use Decode.decode didn't work.
Any idea on how this could be solved?
let decodeEvent = (Decoder(decoder), value: Web_node.event) =>
try decoder(Obj.magic(value)) catch {
| ParseFail(e) => Error(e)
| _ => Error("Unknown JSON parsing error")
}
The purpose of decodeEvent seems to be two-fold:
To convert a Web_node.event to Json.t in order to use Json decoders on it.
To return a result instead of raising an exception on error.
The rescript-json-combinators API already has a result-based API. That's part of the reason why the implementation is now hidden and requires the use of Json.decode to run the decoders. That seems to be all that's missing here:
let decodeEvent = (decoder, value: Web_node.event) =>
value->Obj.magic->Json.decode(decoder)

Unable to resolve flow annotation error when using immutablejs records and calling update on one

I see the following record type code:
type AppProps = {
+fetches: Map<string, number>,
};
export const makeApp: RecordFactory<AppProps> = Immutable.Record({
fetches: Immutable.Map()
});
export type App = RecordOf<AppProps>;
Now I have a call that uses the record's update function:
const state = makeApp({});
const result = state.update('fetches', val =>
val.set(action.meta.actionBase, 1)
);
All unit tests pass, behaviour is good, but I get a flow error:
Error:(40, 18) Missing type annotation for T. T is a type
parameter declared in RecordInstance [1] and was implicitly
instantiated at call of method update [2].
I have an idea what is going on here, but I don't know flow well known to actually fix this, or even come up with a workaround. Please help!
ImmutableJS version "immutable": "^4.0.0-rc.12",
Flow is asking for a concrete type argument for T, which is defined in the update function of state.
Here's another example of a cause and fix of this error message:
Missing annotation error
Fixed
If you provide the type signature of state.update, I may be able to provide more information.

How do I type a function with input and output objects with the same keys but different value types?

Basically, I have a function that will transform an object into a different object, and it's like a dictionary, but I don't know how to type it.
var myFunctions = {
a: () => something1,
b: () => something2,
[...]
}
gets transformed into
var myObject = {
a: something1,
b: something2
[...]
}
With Flow 0.33+ you can use $ObjMap
type ExtractCodomain = <V>(v: () => V) => V;
declare function f<O>(o: O): $ObjMap<O, ExtractCodomain>;
I don't think you can do this with Flow. The closest you can get is probably this:
function<T>(obj: T): ([key: $Keys<T>]: boolean)
That function is typed to return an object with the same key as input object, but with boolean-only values (as an example, you can specify another type). Sorry to disappoint, but it's hard to type highly dynamic code with Flow in general.
Note that the $Keys feature is undocumented because it's not part of the public API, so its behavior is defined solely by its implementation (in other words, it can change anytime).
If you're interested in the details of Flow's type system, check out the typings that come with flow in its own /lib directory, for example https://github.com/facebook/flow/blob/master/lib/core.js – you'll see that some things like Object.assign are special-cased, so you might not be able to re-implement such things in your own code.
Also, check out http://sitr.us/2015/05/31/advanced-features-in-flow.html for other "dollar features" such as $Shape and $Diff – it's partially outdated, but can give some good pointers.
#Nikita gave you the best answer for now. That said, the use-case you talked about is being discussed in the issues on the FlowType repository. It may land soon.
As of right now, if you've got mixed type, I'll just fallback to any
function<T>(obj: T): ([key: $Keys<T>]: any)
This way, at least the key names are validated. I expect within a few more versions of Flow, this problem will get solved.

RubyMotion Firebase (motion-firebase) How to retrieve data?

Using the motion-firebase library for RubyMotion Firebase (https://github.com/colinta/motion-firebase) I can set data easy enough either by doing:
firebase.set({ full_name: ['first_name' => 'Fred', 'last_name' => 'Flintstone'] })
or
firebase['first_name'] = 'Fred'
But I'm having trouble figuring out how to retrieve data.
I've tried the different firebase.query methods listed in the reponse readme but I'm definitely missing something.
I'd hoped it would be as simple as:
firebase.query['first_name']
=> 'Fred'
Could someone please explain how I might go about querying Firebase with a key and returning the value.
colinta here! You'll need to attach an observer (https://github.com/colinta/motion-firebase#attaching-observers-to-read-data).
firebase_ref.once(:value) { |snapshot| snapshot.value }
See https://www.firebase.com/docs/ios-api/Classes/FDataSnapshot.html for info on the FDataSnapshot type.

Dbms_datadump fails with ORA-39117 for a table with user defined type

I have a table which has column of user defined type, I tried to move the table to a different schema,
It worked fine using command line mode, however when I tries to use DBMS_DATAPUMP, it fails with ORA-39117 error, below are the filters I had used.
Command Line Mode:
bin/expdp user1/password1 directory=TEST_DIR1 include=TABLE:\"=\'TEST_TABLE_1\'\",TYPE:\"IN \(\'TEST_TYPE_1\'\)\" reuse_dumpfiles=y dumpfile=TEST.dmp logfile=expdpTEST.log
bin/impdp user1/password1 directory=TEST_DIR1 include=TABLE:\"=\'TEST_TABLE_1\'\",,TYPE:\"IN \(\'TEST_TYPE_1\'\)\" dumpfile=TEST.dmp logfile=impdpTEST.log remap_schema=USER1:USER2 TRANSFORM=oid:n
With the above command, table movement was successful. But we would like to do the same thing using pl/sql block.
===Export===
DBMS_DATAPUMP.metadata_filter (
handle => h1,
name => 'NAME_EXPR',
VALUE => 'IN(''TEST_TABLE_1'',''TEST_TYPE_1'')'
);
dbms_datapump.metadata_filter(
handle => h1, name => 'INCLUDE_PATH_EXPR', value => 'IN (''TABLE'',''TYPE'')');
===Import===
DBMS_DATAPUMP.metadata_filter (
handle => h1,
name => 'NAME_EXPR',
VALUE => 'IN(''TEST_TABLE_1'',''TEST_TYPE_1'')'
);
dbms_datapump.metadata_filter(
handle => h1, name => 'INCLUDE_PATH_EXPR', value => 'IN (''TABLE'',''TYPE'')');
This problem may have nothing to do with impdp vs DBMS_DATAPUMP. I used to have many problems importing object-relational tables. We never found a solution and the problem appeared to be "random" - it would work one day and fail another for reasons we never discovered. If I remember correctly, we guessed there were problems with object-relational dependencies and fixed the problem by manually importing a few types before the rest of the import.
Another possibility is that the import succeeded and the error message is wrong. See Doc ID 783358.1 - ORA-39117 Incorrectly Reported At Impdp Level, on support.oracle.com.

Resources