Akita 3 update: " Remove noop - use the of() observable." done what does that mean? - angular-akita

In Akita I could
return noop
but after the upgrade they left this instruction as they removed noop as a breaking change;
Remove noop - use the of() observable. done
what does that mean? an example please?

of() observable is the equivalent of noop only that it's built-in in RxJS.

Related

I found something confusing in the documentation at https://docs.pytest.org/en/latest/fixture.html# and here is what I did about it

I am learning pytest, which gives me an advantage: I'm utterly clueless, so I can I tell you what I found confusing and how I got around it.
In https://docs.pytest.org/en/latest/fixture.html#, there are two example python files: test_module.py and test_smtpsimple.py. What I found confusing about the examples is there are two methods, smtp_connection.ehlo() and smtp_connection.noop(). It is not intuitively obvious that these are methods of objects of class smtplib.SMTP. Of course, they are. I had to dig through some software to figure that out.
In https://docs.pytest.org/en/latest/fixture.html#, there are two example python files: test_module.py and test_smtpsimple.py. What I found confusing about the examples is there are two methods, smtp_connection.ehlo() and smtp_connection.noop(). It is not intuitively obvious that these are methods of objects of class smtplib.SMTP. Of course, they are. I had to dig through some software to figure that out.
So I modified the code with some comments to make it easier, I hope, for somebody learning pytest.
def test_noop(smtp_connection):
# See https://docs.python.org/3/library/smtplib.html#smtp-objects
# The documentation there says that the noop method is not documented there.
response, msg = smtp_connection.noop()
assert response == 250
assert 0 # for demo purposes
and
def smtp_connection():
import smtplib
# This isn't clear from https://docs.pytest.org/en/latest/fixture.html but smtplib has
# at least two attributes: ehlo and noop
print ( dir(smtplib.SMTP), file=sys.stderr )
# Return an object of class smtplib.SMTP which has methods ehlo and noop
return smtplib.SMTP("smtp.gmail.com", 587, timeout=5)
def test_ehlo(smtp_connection):
# smtp_connection is an object of type smtplib.SMTP.
# See https://docs.python.org/3/library/smtplib.html#smtp-objects
# The documentation there says that the noop method is not documented there.
response, msg = smtp_connection.ehlo()
assert response == 250
assert 0 # for demo purposes
To make it even clearer, I might print the object id of smtp_connection as it works its ways through the code. That might be overkill.

Specman e: "keep type .. is a" fails to refine the type of a field

I have the next code in my verification environment:
// seq_file.e
extend SPECIFIC_TYPE sequence {
keep type driver is a SPECIFIC_TYPE sequence_driver;
event some_event is #driver.as_a(SPECIFIC_TYPE sequence_driver).some_event;
};
extend SPECIFIC_TYPE SEQ_NAME sequence {
body()#driver.clock is only {
var foo := driver.specific_type_field;
};
};
Note that thank to keep type driver is a.. there is no need in driver's casting in the line starting var foo..
BUT, the keep type driver is a.. does not affect the some_event, i.e. if the as_a casting is removed from the line, there is a compilation error says 'driver' does not have 'some_event' though its subtype do. use driver.as_a(SPECIFIC_TYPE sequence_driver).
Why the keep type driver is a.. fails to cast the driver in some_event.. line?
Thank you for your help
Your observation is correct: type constraint is taken into account for a field access (and for a method call), but not for event sampling. This is a limitation, and it might be removed in upcoming versions. I suggest contacting official Specman support for the exact info on the plans.

Flatmap my observable to subject

The question is a little tricky.
I am trying to implement the observable interface, within it i need to start listen to another publicsubject once the observable meet some circustance, so i write some code like this:
public myAPI(){
return restAPI.call()
.flatmap{ ret ->
if(ret == success) return myPublishSubject
}
can it guarantee the subscribe start subscribe to the publishsubject only after restAPI call is done successfully ?
The flatMap's Function callback is invoked when there is a value from upstream, in this case, the restAPI.call().
However, note that mapping to a PublishSubject late can result in items being missed. To avoid such problems, you can consider using BehaviorSubject that retains the last item it received so the flatMap can emit immediately upon subscribing to it.
In addition, repeatedly mapping to the same Subject can result in memory leaks and item duplication. Unfortunately, you'd have to complete the Subject in order to release it, but then it becomes unusable for dispatching further events. takeUntil may help in this case though.

Postfix or infix form?

Postfix form is not recommended in Scala at least according to IntelliJ Idea. I think I even have read about it. While infix is recommended. I wonder, what the form is here:
val out = new OutputStreamWriter(connection.getOutputStream)
out write text // infix
out flush () // postfix or infix?
I could have written out flush() and it would be postfix form, correct?
However, I could also have done out flush () (pay attention to a white-space) and it seems to be infix form where out is an object, flush is a method and () - is empty parameter list of type Unit- just like out write text, but instead of text we have Unit or ().
Is this postfix or infix form?
As far as style guidance is concerned, neither out flush() nor out flush () is postfix - because of the parentheses. out flush would be considered postfix. the difference is that the scala parser behaves oddly with semicolon inference and postfix operators, as discussed here. By adding the parentheses after flush, you remove the possibility that your statement will be parsed in a way you don't expect. I would use out flush(). Adding parentheses directly after the name of the method is the standard for methods with side effects

overriden bang (!) operator. Find sender

When I override the bang (!) operator in Scala, it's invoked on the actor which is the recipient of the message. Is there a way I can find out who sent this msg to this actor inside the overridden bang operator?
Thanks,
Please see here how to override the behavior of the bang operator. In your particular case you can override it by wrapping the original message in an envelop containing the sender.
How to override bang operator(!) for different type of inputs in scala
How to overload bang(!) operator in Scala Actor model?
Also, please note that the Scala 2.9's actors API will become deprecated. Consider using Akka instead which does provide the functionality you are looking for.